loop through each instance, wait for a new one to come up, then deregister and terminate the old one

This commit is contained in:
Anuj Biyani
2013-06-03 16:19:03 -07:00
parent 9273f748c2
commit b463901f98
5 changed files with 70 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ class AwsHaRelease
end
@max_size_change = 0
@inservice_polling_time = 10
end
def execute!
@@ -23,6 +24,30 @@ class AwsHaRelease
end
@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
deregister_instance instance, @group.load_balancers
sleep opts[:elb_timeout]
instance.terminate false
end
@group.update(desired_capacity: @group.desired_capacity - 1)
if @max_size_change > 0
@group.update(max_size: @group.max_size - @max_size_change)
end
@group.resume_all_processes
end
def deregister_instance(instance, load_balancers)
load_balancers.each do |load_balancer|
load_balancer.instances.deregister instance
end
end
def instances_inservice?(load_balancer)