How to make "Installing Cookbook Gems:" faster


#1

Hi,

Whenever I run ‘kitchen converge’, the “Installing Cookbook Gems:” part takes pretty long time to pass.
I tried using a proxy configuring .kitchen.yml as follow

provisioner:
name: chef_zero
chef_omnibus_url: http://repo.example.net/install_chef_script.sh
http_proxy: http://proxy.example.net:8000
https_proxy: http://proxy.example.net:8000

and added following script in the install_chef_script.sh to make embedded ruby gem refers that file after installing chef client.

sudo bash -c “cat << EOF > /opt/chef/embedded/etc/gemrc
gem: --no-ri --no-rdoc
benchmark: false
verbose: true
update_sources: true
sources:
- http://rubygems.org/
backtrace: true
bulk_threshold: 1000
EOF”

But after that, it still takes long time connecting the proxy server but downloading gem files using https://rubygems.org/ which doesn’t cache contents. I expect it will be faster when using http since the proxy(squid) caches contents when used with http.

Is there some way to configure ‘sources’ repos for embedded ruby gem to change the default one with ‘http’? or Is there someone who knows better approach to solve this problem?

Please help
Dongwon


#2

While you can technically use the rubygems_url config option in your client.rb or solo.rb to change this, I should point out that like most websites, rubygems.org no longer allows non-HTTPS requests so you’ll just get redirected anyway. If you need to run an internal mirror, I would do that and then point rubygems_url at that instead.


#3

That’s good to know that http request is being redirected. I guess I should probably setup a local mirror as you said.
Thank you for your advice!


#4

How do you stop “Installing Cookbook Gems” running at all? If we know that then it’s possible to create a timestamp file that will restrict it to running eg once per day.


#5

There isn’t really a way to disable the installing of gems if they are set in metadata.rb of a cookbook as this is an in-built feature of chef-client. At least nothing short of making sure that no cookbooks in a given dependency tree utilize this feature so that it would be effectively a no-op.


#6

FYI: Using Vagrant + VMWare Fusion I have super slow DNS resolving for SRV records which are used by rubygems. As you are using test-kitchen, maybe you have the same issue? Details at https://github.com/chef/bento/issues/941 - usually circumventing the VMWare Fusion DNS proxy by using Google DNS or any other speeds up any rubygems taks.