Skip to content

Commit

Permalink
Update openstacklib to aafb9b05dac6aedf69f1317acf50d4ec851bbbd6
Browse files Browse the repository at this point in the history
def1e83 Adjust timeout for non-retry calls
c66591e Add optional exceptions regex to avoid to retry.

Change-Id: I197c6cfe714fc250ca481d6d9d2e808e5163560d
  • Loading branch information
apevec committed Jul 13, 2016
1 parent 046ed1b commit 9fe044f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 15 additions & 4 deletions openstacklib/lib/puppet/provider/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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>,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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions openstacklib/lib/puppet/provider/openstack/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- Add the possibility to exclude some exception from retry
mechanism. It helps to fix `bug 1597357
<https://bugs.launchpad.net/puppet-keystone/+bug/1597357>`__

0 comments on commit 9fe044f

Please sign in to comment.