lib/kitchen/driver/ec2.rb in kitchen-ec2-3.11.0 vs lib/kitchen/driver/ec2.rb in kitchen-ec2-3.11.1
- old
+ new
@@ -284,17 +284,20 @@
end
# If we are going to clean up an automatic security group, we need
# to wait for the instance to shut down. This slightly breaks the
# subsystem encapsulation, sorry not sorry.
if state[:auto_security_group_id] && server && ec2.instance_exists?(state[:server_id])
- server.wait_until_terminated do |waiter|
- waiter.max_attempts = config[:retryable_tries]
- waiter.delay = config[:retryable_sleep]
- waiter.before_attempt do |attempts|
- info "Waited #{attempts * waiter.delay}/#{waiter.delay * waiter.max_attempts}s for instance <#{server.id}> to terminate."
- end
+ wait_log = proc do |attempts|
+ c = attempts * config[:retryable_sleep]
+ t = config[:retryable_tries] * config[:retryable_sleep]
+ info "Waited #{c}/#{t}s for instance <#{server.id}> to terminate."
end
+ server.wait_until_terminated(
+ max_attempts: config[:retryable_tries],
+ delay: config[:retryable_sleep],
+ before_attempt: wait_log
+ )
end
info("EC2 instance <#{state[:server_id]}> destroyed.")
state.delete(:server_id)
state.delete(:hostname)
end
@@ -363,10 +366,10 @@
# us no way to distinguish a user-set value from the transport's default.
# See https://github.com/test-kitchen/kitchen-ec2/pull/273
if actual_platform &&
instance.transport[:username] == instance.transport.class.defaults[:username]
debug("No SSH username specified: using default username #{actual_platform.username} " \
- " for image #{config[:image_id]}, which we detected as #{actual_platform}.")
+ "for image #{config[:image_id]}, which we detected as #{actual_platform}.")
state[:username] = actual_platform.username
end
end
def ec2