Permalink
Browse files

raise timeout to an INSANE amount, output timing info

  • Loading branch information...
1 parent 36143b4 commit a31f650cd9dfc884b64f40bc8d0b76a77dbae92f Alex Jackson and Martin Englund committed Mar 18, 2013
Showing with 11 additions and 5 deletions.
  1. +11 −5 bosh_aws_cpi/lib/cloud/aws/resource_wait.rb
View
16 bosh_aws_cpi/lib/cloud/aws/resource_wait.rb
@@ -1,7 +1,7 @@
module Bosh::AwsCloud
class ResourceWait
- DEFAULT_TRIES = 15
+ DEFAULT_TRIES = 100 # this is an INSANE amount of retries, but AWS doesn't give us choice
MAX_SLEEP_EXPONENT = 8
def self.for_instance(args)
@@ -34,10 +34,13 @@ def self.for_attachment(args)
ignored_errors = []
if target_state == :attached
- ignored_errors = [AWS::Core::Resource::NotFound]
+ ignored_errors << AWS::Core::Resource::NotFound
end
+ description = "volume %s to be %s to instance %s as device %s" % [
+ attachment.volume.id, target_state, attachment.instance.id, attachment.device
+ ]
- new.for_resource(resource: attachment, errors: ignored_errors, target_state: target_state, description: attachment.to_s) do |current_state|
+ new.for_resource(resource: attachment, errors: ignored_errors, target_state: target_state, description: description) do |current_state|
current_state == target_state
end
rescue AWS::Core::Resource::NotFound
@@ -137,7 +140,7 @@ def for_resource(args)
end
ensure_cb = Proc.new do |retries|
- cloud_error("Timed out waiting for #{desc} to be #{target_state}") if retries == tries
+ cloud_error("Timed out waiting for #{desc} to be #{target_state}, took #{time_passed}s") if retries == tries
end
state = nil
@@ -147,14 +150,17 @@ def for_resource(args)
state = resource.method(state_method).call
if state == :error || state == :failed
- raise Bosh::Clouds::CloudError, "#{desc} state is #{state}, expected #{target_state}"
+ raise Bosh::Clouds::CloudError, "#{desc} state is #{state}, expected #{target_state}, took #{time_passed}s"
end
# the yielded block should return true if we have reached the target state
yield state
end
Bosh::AwsCloud::ResourceWait.logger.info("#{desc} is now #{state}, took #{time_passed}s")
+ rescue RetryCountExceeded => e
+ Bosh::AwsCloud::ResourceWait.logger.error("Timed out waiting for #{desc} state is #{state}, expected to be #{target_state}, took #{time_passed}s")
+ raise e
end
def time_passed

0 comments on commit a31f650

Please sign in to comment.