suspend certain autoscaling processes before cycling servers

This commit is contained in:
Anuj Biyani 2013-05-31 15:05:16 -07:00
parent 4f466e1a19
commit 6f74b5c511
4 changed files with 26 additions and 2 deletions

View File

@ -27,4 +27,4 @@ if opts[:aws_access_key].nil? || opts[:aws_secret_key].nil?
end end
require 'aws-missing-tools' require 'aws-missing-tools'
AwsHaRelease.new(opts) AwsHaRelease.new(opts).execute!

View File

@ -9,4 +9,8 @@ class AwsHaRelease
raise ArgumentError, "The Auto Scaling Group named #{opts[:as_group_name]} does not exist in #{opts[:region]}." raise ArgumentError, "The Auto Scaling Group named #{opts[:as_group_name]} does not exist in #{opts[:region]}."
end end
end end
def execute!
@group.suspend_processes 'ReplaceUnhealthy', 'AlarmNotification', 'ScheduledActions', 'AZRebalance'
end
end end

View File

@ -19,7 +19,7 @@ describe 'aws-ha-release' do
describe '#initialize' do describe '#initialize' do
it 'initializes the AWS connection' do it 'initializes the AWS connection' do
as.groups.create 'test_group' as.groups.create opts[:as_group_name]
AWS.should_receive(:config).with(access_key_id: 'testaccesskey', secret_access_key: 'testsecretkey', region: 'test-region') AWS.should_receive(:config).with(access_key_id: 'testaccesskey', secret_access_key: 'testsecretkey', region: 'test-region')
AwsHaRelease.new(opts) AwsHaRelease.new(opts)
@ -31,4 +31,17 @@ describe 'aws-ha-release' do
}.should raise_error }.should raise_error
end end
end end
describe '#execute!' do
before do
as.groups.create opts[:as_group_name]
@aws_ha_release = AwsHaRelease.new(opts)
end
it 'suspends certain autoscaling processes' do
AWS::FakeAutoScaling::Group.any_instance.should_receive(:suspend_processes)
.with('ReplaceUnhealthy', 'AlarmNotification', 'ScheduledActions', 'AZRebalance')
@aws_ha_release.execute!
end
end
end end

View File

@ -26,6 +26,13 @@ module AWS
def initialize(name) def initialize(name)
@name = name @name = name
@suspended_processes = {}
end
def suspend_processes(*processes)
processes.each do |process|
@suspended_processes[process] = 'test'
end
end end
end end
end end