diff --git a/NATIVE_TYPES_AND_PROVIDERS.md b/NATIVE_TYPES_AND_PROVIDERS.md index d2d4c5e11..48cd77570 100644 --- a/NATIVE_TYPES_AND_PROVIDERS.md +++ b/NATIVE_TYPES_AND_PROVIDERS.md @@ -124,8 +124,6 @@ class { '::jenkins': include ::jenkins::cli_helper ``` -The ruby gem `retries` is presently required by all providers. - ### `puppetserver` There is a known issue with `puppetserver` being unable to load code from @@ -144,13 +142,6 @@ jruby-puppet: { See [SERVER-973](https://tickets.puppetlabs.com/browse/SERVER-973) -Additionally, the `retries` gem is required. This may be installed on the master by running: - -``` -/opt/puppetlabs/bin/puppetserver gem install retries -``` - - Types -- diff --git a/lib/puppet/feature/retries.rb b/lib/puppet/feature/retries.rb deleted file mode 100644 index 1b0bf8eef..000000000 --- a/lib/puppet/feature/retries.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet/util/feature' - -Puppet.features.add(:retries, libs: 'retries') diff --git a/lib/puppet/x/jenkins/provider/cli.rb b/lib/puppet/x/jenkins/provider/cli.rb index 7d9650f03..ca84bed12 100644 --- a/lib/puppet/x/jenkins/provider/cli.rb +++ b/lib/puppet/x/jenkins/provider/cli.rb @@ -27,7 +27,6 @@ def self.inherited(subclass) initvars commands java: 'java' - confine feature: :retries # subclasses should inherit this value once it has been determined that # jenkins requires authorization, it shortens the run time be elemating the @@ -220,19 +219,18 @@ def self.execute_with_retry(command, options = {}, cli_pre_cmd = []) # retry on "unknown" execution errors but don't catch AuthErrors. If an # AuthError has bubbled up to this level it means either an ssh_private_key # is required and we don't have one or that one we have was rejected. - handler = proc do |exception, attempt_number, total_delay| - Puppet.debug("#{sname} caught #{exception.class.to_s.match(%r{::([^:]+)$})[1]}; retry attempt #{attempt_number}; #{total_delay.round(3)} seconds have passed") - end - with_retries( - max_tries: cli_tries, - base_sleep_seconds: 1, - max_sleep_seconds: cli_try_sleep, - rescue: [UnknownError, NetError], - handler: handler - ) do + attempt_number = 0 + begin result = execute_with_auth(cli_cmd, auth_cmd, options) Puppet.debug("#{sname} command stdout:\n#{result}") unless result == '' return result + rescue [UnknownError, NetError] => exception + Puppet.debug("#{sname} caught #{exception.class.to_s.match(%r{::([^:]+)$})[1]}; retry attempt #{attempt_number}") + if attempt < cli_tries + attempt += 1 + sleep(cli_try_sleep) + retry + end end end private_class_method :execute_with_retry diff --git a/manifests/cli/config.pp b/manifests/cli/config.pp index ec008b787..faa581902 100644 --- a/manifests/cli/config.pp +++ b/manifests/cli/config.pp @@ -20,29 +20,10 @@ Optional[Boolean] $cli_remoting_free = undef, Optional[String] $ssh_private_key_content = undef, ) { - - if str2bool($facts['is_pe']) { - $gem_provider = 'pe_gem' - # lint:ignore:legacy_facts - } elsif $facts['rubysitedir'] and ('/opt/puppetlabs/puppet/lib/ruby' in $facts['rubysitedir']) { - # lint:endignore - # AIO puppet - $gem_provider = 'puppet_gem' - } else { - $gem_provider = 'gem' - } - # lint:ignore:legacy_facts $is_root = $facts['id'] == 'root' # lint:endignore - # required by PuppetX::Jenkins::Provider::Clihelper base - if ! defined(Package['retries']) { - package { 'retries': - provider => $gem_provider, - } - } - if $ssh_private_key and $ssh_private_key_content { file { $ssh_private_key: ensure => 'file', diff --git a/spec/classes/cli/config_spec.rb b/spec/classes/cli/config_spec.rb index c3545b015..bc318dbc8 100644 --- a/spec/classes/cli/config_spec.rb +++ b/spec/classes/cli/config_spec.rb @@ -122,26 +122,6 @@ end # when ssh_private_key is also set end # ssh_private_key_content end # parameters - - describe 'package gem provider' do - context 'is_pe fact' do - context 'true' do - let :facts do - super().merge(is_pe: true) - end - - it { is_expected.to contain_package('retries').with(provider: 'pe_gem') } - end - - context 'false' do - let :facts do - super().merge(is_pe: false) - end - - it { is_expected.to contain_package('retries').with(provider: 'gem') } - end - end # 'is_pe fact' do - end # 'package gem provider' do end end end diff --git a/spec/unit/puppet/x/jenkins/provider/cli_spec.rb b/spec/unit/puppet/x/jenkins/provider/cli_spec.rb index 1a75b0a74..467a66581 100644 --- a/spec/unit/puppet/x/jenkins/provider/cli_spec.rb +++ b/spec/unit/puppet/x/jenkins/provider/cli_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' require 'unit/puppet/x/spec_jenkins_providers' -# we need to make sure retries is always loaded or random test ordering can -# cause failures when a side effect hasn't yet caused the lib to be loaded -require 'retries' require 'puppet/x/jenkins/provider/cli' describe Puppet::X::Jenkins::Provider::Cli do @@ -309,13 +306,6 @@ end # ::clihelper describe '::cli' do - before do - # disable with_retries sleeping to [vastly] speed up testing - # - # we are relying the side effects of ::suitable? from a previous example - Retries.sleep_enabled = false - end - shared_examples 'uses default values' do it 'uses default values' do expect(described_class.superclass).to receive(:execute).with( @@ -575,7 +565,9 @@ ) catalog.add_resource jenkins - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 2)) + expect(described_class.superclass).to receive(:execute_with_auth).and_raise(AuthError) + expect(sleep).to receive(2) + expect(described_class.superclass).to receive(:execute_with_auth) described_class.cli('foo', catalog: catalog) end @@ -587,7 +579,9 @@ ) catalog.add_resource jenkins - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 3)) + expect(described_class.superclass).to receive(:execute_with_auth).and_raise(AuthError) + expect(sleep).to receive(3) + expect(described_class.superclass).to receive(:execute_with_auth) described_class.cli('foo', catalog: catalog) end @@ -600,7 +594,9 @@ ) catalog.add_resource jenkins - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 4)) + expect(described_class.superclass).to receive(:execute_with_auth).and_raise(AuthError) + expect(sleep).to receive(4) + expect(described_class.superclass).to receive(:execute_with_auth) described_class.cli('foo', catalog: catalog) end @@ -614,7 +610,9 @@ ) catalog.add_resource jenkins - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 3)) + expect(described_class.superclass).to receive(:execute_with_auth).and_raise(AuthError) + expect(sleep).to receive(3) + expect(described_class.superclass).to receive(:execute_with_auth) described_class.cli('foo', catalog: catalog) end diff --git a/spec/unit/puppet/x/spec_jenkins_providers.rb b/spec/unit/puppet/x/spec_jenkins_providers.rb index 32861e41e..a401a3726 100644 --- a/spec/unit/puppet/x/spec_jenkins_providers.rb +++ b/spec/unit/puppet/x/spec_jenkins_providers.rb @@ -10,15 +10,6 @@ described_class.confine_collection.instance_variable_get(:@confines) end - context 'feature :retries' do - it do - expect(confines).to include( - be_kind_of(Puppet::Confine::Feature). - and(have_attributes(values: [:retries])) - ) - end - end - context 'commands :java' do it do expect(confines).to include(