timeout if cycling a server takes longer than inservice_time_allowed

This commit is contained in:
Anuj Biyani
2013-06-03 18:51:01 -07:00
parent 55e60a989e
commit 07fc0390f7
6 changed files with 28 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
require 'timeout'
class AwsHaRelease
attr_reader :group
@@ -13,6 +15,7 @@ class AwsHaRelease
@max_size_change = 0
@inservice_polling_time = 10
@opts = opts
end
def execute!
@@ -26,13 +29,15 @@ class AwsHaRelease
@group.update(desired_capacity: @group.desired_capacity + 1)
@group.ec2_instances.each do |instance|
until all_instances_inservice?(@group.load_balancers)
sleep @inservice_polling_time
end
Timeout::timeout(@opts[:inservice_time_allowed]) do
until all_instances_inservice?(@group.load_balancers)
sleep @inservice_polling_time
end
deregister_instance instance, @group.load_balancers
sleep opts[:elb_timeout]
instance.terminate false
deregister_instance instance, @group.load_balancers
sleep @opts[:elb_timeout]
instance.terminate false
end
end
@group.update(desired_capacity: @group.desired_capacity - 1)