ensure that necessary autoscaling processes are not suspended

This commit is contained in:
Anuj Biyani 2013-06-03 19:31:10 -07:00
parent 8c24fa8dbf
commit 5f4b9b59bf
3 changed files with 12 additions and 3 deletions

View File

@ -20,6 +20,12 @@ class AwsHaRelease
end
def execute!
%w(RemoveFromLoadBalancerLowPriority Terminate Launch HealthCheck AddToLoadBalancer).each do |process|
if @group.suspended_processes.keys.include? process
raise "AutoScaling process #{process} is currently suspended on #{@group.name} but is necessary for this script."
end
end
@group.suspend_processes @processes_to_suspend
if @group.max_size == @group.desired_capacity

View File

@ -46,7 +46,10 @@ describe 'aws-ha-release' do
@aws_ha_release.execute!
end
it 'requires certain autoscaling processes to not be suspended'
it 'requires certain autoscaling processes to not be suspended' do
@aws_ha_release.group.suspend_processes %w(RemoveFromLoadBalancerLowPriority Terminate Launch HealthCheck AddToLoadBalancer)
expect{ @aws_ha_release.execute! }.to raise_error
end
it 'adjusts the max size as well as the desired capacity if the desired capacity is equal to it' do
@group.update(max_size: 1, desired_capacity: 1)

View File

@ -22,7 +22,7 @@ module AWS
end
class Group
attr_reader :name, :max_size, :desired_capacity
attr_reader :name, :max_size, :desired_capacity, :suspended_processes
def initialize(name)
@name = name
@ -31,7 +31,7 @@ module AWS
@desired_capacity = 1
end
def suspend_processes(*processes)
def suspend_processes(processes)
processes.each do |process|
@suspended_processes[process] = 'test'
end