diff --git a/Puppetfile b/Puppetfile index 5f6d3f673..99d487922 100644 --- a/Puppetfile +++ b/Puppetfile @@ -175,7 +175,7 @@ mod 'openstack_extras', :git => 'https://github.com/openstack/puppet-openstack_extras.git' mod 'openstacklib', - :commit => '5ee5a0c947c1e219cc47dbb07f3e5ad4dccd5197', + :commit => 'aafb9b05dac6aedf69f1317acf50d4ec851bbbd6', :git => 'https://github.com/openstack/puppet-openstacklib.git' mod 'pacemaker', diff --git a/openstacklib/lib/puppet/provider/openstack.rb b/openstacklib/lib/puppet/provider/openstack.rb index a5b60fd4c..901e33438 100644 --- a/openstacklib/lib/puppet/provider/openstack.rb +++ b/openstacklib/lib/puppet/provider/openstack.rb @@ -43,11 +43,12 @@ def self.command_timeout(action=nil) # with command_timeout def self.openstack(*args) begin - Timeout.timeout(command_timeout) do + action = args[1] + Timeout.timeout(command_timeout(action)) do openstack_command *args end rescue Timeout::Error - raise Puppet::ExecutionFailure, "Command: 'openstack #{args.inspect}' has been running for more then #{command_timeout(action)} seconds" + raise Puppet::ExecutionFailure, "Command: 'openstack #{args.inspect}' has been running for more than #{command_timeout(action)} seconds" end end @@ -70,8 +71,13 @@ def self.request_without_retry(&block) # Returns an array of hashes, where the keys are the downcased CSV headers # with underscores instead of spaces - def self.request(service, action, properties, credentials=nil) + # + # @param options [Hash] Other options + # @options :no_retry_exception_msgs [Array,Regexp] exception without retries + def self.request(service, action, properties, credentials=nil, options={}) env = credentials ? credentials.to_env : {} + no_retry = options[:no_retry_exception_msgs] + Puppet::Util.withenv(env) do rv = nil end_time = current_time + request_timeout @@ -120,8 +126,13 @@ def self.request(service, action, properties, credentials=nil) end raise exception if no_retry_actions.include? action + if no_retry + no_retry = [no_retry] unless no_retry.is_a?(Array) + no_retry.each do |nr| + raise exception if exception.message.match(nr) + end + end debug "Non-fatal error: '#{exception.message}'. Retrying for #{end_time - current_time} more seconds" - raise exception if no_retry_actions.include? action sleep retry_sleep retry_count += 1 retry diff --git a/openstacklib/lib/puppet/provider/openstack/auth.rb b/openstacklib/lib/puppet/provider/openstack/auth.rb index 1dc7e3db7..584bfc728 100644 --- a/openstacklib/lib/puppet/provider/openstack/auth.rb +++ b/openstacklib/lib/puppet/provider/openstack/auth.rb @@ -29,7 +29,7 @@ def rc_filename RCFILENAME end - def request(service, action, properties=nil) + def request(service, action, properties=nil, options={}) properties ||= [] set_credentials(@credentials, get_os_vars_from_env) unless @credentials.set? @@ -39,7 +39,7 @@ def request(service, action, properties=nil) unless @credentials.set? raise(Puppet::Error::OpenstackAuthInputError, 'Insufficient credentials to authenticate') end - super(service, action, properties, @credentials) + super(service, action, properties, @credentials, options) end def set_credentials(creds, env) diff --git a/openstacklib/releasenotes/notes/feature_add_exclusion_to_retry_mechanism-2acb52fa25bd315c.yaml b/openstacklib/releasenotes/notes/feature_add_exclusion_to_retry_mechanism-2acb52fa25bd315c.yaml new file mode 100644 index 000000000..81b1d1b15 --- /dev/null +++ b/openstacklib/releasenotes/notes/feature_add_exclusion_to_retry_mechanism-2acb52fa25bd315c.yaml @@ -0,0 +1,5 @@ +--- +features: + - Add the possibility to exclude some exception from retry + mechanism. It helps to fix `bug 1597357 + `__