use fake time instead of real time when measuring against inservice_time_allowed

This commit is contained in:
Anuj Biyani 2013-06-10 14:04:15 -07:00
parent 1b5acf6ede
commit c493f2e188

View File

@ -97,33 +97,30 @@ module AwsMissingTools
@group.auto_scaling_instances.each do |instance| @group.auto_scaling_instances.each do |instance|
time_taken = 0 time_taken = 0
begin until all_instances_inservice_for_time_period?(@group.load_balancers, INSERVICE_POLLING_TIME)
Timeout::timeout(@opts[:inservice_time_allowed]) do puts "#{time_taken} seconds have elapsed while waiting for all instances to be InService for a minimum of #{@opts[:min_inservice_time]} seconds."
until all_instances_inservice_for_time_period?(@group.load_balancers, INSERVICE_POLLING_TIME) if time_taken >= @opts[:inservice_time_allowed]
puts "#{time_taken} seconds have elapsed while waiting for all instances to be InService for a minimum of #{@opts[:min_inservice_time]} seconds." puts "\nDuring the last #{time_taken} seconds, a new AutoScaling instance failed to become healthy."
puts "The following settings were changed and will not be changed back by this script:\n"
time_taken += INSERVICE_POLLING_TIME puts "AutoScaling processes #{PROCESSES_TO_SUSPEND} were suspended."
sleep INSERVICE_POLLING_TIME puts "The desired capacity was changed from #{@group.desired_capacity - 1} to #{@group.desired_capacity}."
if @max_size_change > 0
puts "The maximum size was changed from #{@group.max_size - @max_size_change} to #{@group.max_size}"
end end
puts "\nThe new instance was found to be healthy; one old instance will now be removed from the load balancers." raise
deregister_instance instance.ec2_instance, @group.load_balancers else
time_taken += INSERVICE_POLLING_TIME
sleep INSERVICE_POLLING_TIME
end end
rescue Timeout::Error => e
puts "\nDuring the last #{time_taken} seconds, a new AutoScaling instance failed to become healthy."
puts "The following settings were changed and will not be changed back by this script:\n"
puts "AutoScaling processes #{PROCESSES_TO_SUSPEND} were suspended."
puts "The desired capacity was changed from #{@group.desired_capacity - 1} to #{@group.desired_capacity}."
if @max_size_change > 0
puts "The maximum size was changed from #{@group.max_size - @max_size_change} to #{@group.max_size}"
end
raise
end end
puts "\nThe new instance was found to be healthy; one old instance will now be removed from the load balancers."
deregister_instance instance.ec2_instance, @group.load_balancers
puts "Sleeping for the ELB Timeout period of #{@opts[:elb_timeout]}" puts "Sleeping for the ELB Timeout period of #{@opts[:elb_timeout]}"
sleep @opts[:elb_timeout] sleep @opts[:elb_timeout]