From c493f2e188aadce72bf81c5440d17f177f792957 Mon Sep 17 00:00:00 2001 From: Anuj Biyani Date: Mon, 10 Jun 2013 14:04:15 -0700 Subject: [PATCH] use fake time instead of real time when measuring against inservice_time_allowed --- .../aws-ha-release/aws-ha-release.rb | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb b/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb index 0996bce..1f6a028 100755 --- a/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb +++ b/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb @@ -97,33 +97,30 @@ module AwsMissingTools @group.auto_scaling_instances.each do |instance| time_taken = 0 - begin - Timeout::timeout(@opts[:inservice_time_allowed]) do + until all_instances_inservice_for_time_period?(@group.load_balancers, INSERVICE_POLLING_TIME) + 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) - puts "#{time_taken} seconds have elapsed while waiting for all instances to be InService for a minimum of #{@opts[:min_inservice_time]} seconds." + if time_taken >= @opts[:inservice_time_allowed] + 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 - sleep INSERVICE_POLLING_TIME + 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 - 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 + raise + else + time_taken += INSERVICE_POLLING_TIME + sleep INSERVICE_POLLING_TIME 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 + 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]}" sleep @opts[:elb_timeout]