Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'gem list --remote' does not respect proxy settings #460

Closed
karolisc opened this issue Dec 29, 2015 · 2 comments
Closed

'gem list --remote' does not respect proxy settings #460

karolisc opened this issue Dec 29, 2015 · 2 comments

Comments

@karolisc
Copy link

Hi,

I am behind proxy. I have set proxy setting in sensu class
gem_install_options => [{ '--http-proxy' => 'http://1.1.1.1:2222' }]

all puppet runs takes very long time
Notice: Finished catalog run in 155.74 seconds

it looks like it does not pass install_options to the package correctly
as it stuck at /usr/bin/gem list --remote ^sensu-plugin$ until it time outs

manual run:

time /usr/bin/gem list --remote ^sensu-plugin$ --debug -V
Exception `NameError' at /usr/lib/ruby/1.9.1/rubygems/command_manager.rb:177 - uninitialized constant Gem::Commands::ListCommand

*** REMOTE GEMS ***

Exception `Errno::ETIMEDOUT' at /usr/lib/ruby/1.9.1/net/http.rb:762 - Connection timed out - connect(2)
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remote_fetcher.rb:246 - Errno::ETIMEDOUT: Connection timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
sensu-plugin (1.2.0)

real    2m7.807s
user    0m0.504s
sys     0m0.056s
time /usr/bin/gem list --remote ^sensu-plugin$ --http-proxy http://1.1.1.1:2222

*** REMOTE GEMS ***

sensu-plugin (1.2.0)

real    0m1.547s
user    0m0.467s
sys     0m0.071s

Setting global proxy settings kinda "solves" the problem but I need it to be managed through module itself.

/etc/environment
 export http_proxy=http://1.1.1.1:2222

Karolis

@jlambert121
Copy link
Contributor

Would you be able to take a stab at a PR for this? I don't have a proxy server to test this with.

@jaxxstorm
Copy link
Contributor

@karolisc the local sensu gem provider uses the gem provider as its parent:

Puppet::Type.type(:package).provide :sensu_gem, :parent => :gem do

We also explicitly take the install options parameters:

has_feature :versionable, :install_options

Now your issue seems to be with the actual gem list command. We use the upstream gem provider here:

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/gem.rb

And as far as I can tell, there's no ability to pass options to gem list:

 def self.gemlist(options)
    gem_list_command = [command(:gemcmd), "list"]

    if options[:local]
      gem_list_command << "--local"
    else
      gem_list_command << "--remote"
    end
    if options[:source]
      gem_list_command << "--source" << options[:source]
    end
    if name = options[:justme]
      gem_list_command << "^" + name + "$"
    end

    begin
      list = execute(gem_list_command).lines.
        map {|set| gemsplit(set) }.
        reject {|x| x.nil? }
    rescue Puppet::ExecutionFailure => detail
      raise Puppet::Error, "Could not list gems: #{detail}", detail.backtrace
    end

Adding this as part of the module seems out of scope for this particularly provider - I expect you'll have the same issues with the standard puppet provider as well? I'm going to close this, as I think it's a problem with the original puppet provider, not with the sensu gem one.

Please reopen if you think I'm in error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants