kumo_keisei 4.0.4 → 4.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/kumo_keisei/stack.rb +13 -5
- data/spec/integration/stack_spec.rb +45 -1
- data/spec/lib/kumo_keisei/console_jockey_spec.rb +2 -2
- data/spec/lib/kumo_keisei/stack_spec.rb +20 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 165cf70d3650a4c654f88ae17cc9c9a6ba56958f
|
4
|
+
data.tar.gz: cdef8e0988f7d80ea2a26d6b56c5124803c39205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30c611ca554d8c543f0c096df391e619a15e144684ce8062df912a5d8a91c5f6b2a13161e913f3ed56c90e1e4f161d7297a2d6da519898ee001318fad4b372bc
|
7
|
+
data.tar.gz: 5f0134857aca2716e901e1abba559881c0048b4afd3000236df6eb87cdef8aaa4d060e1f819549df55db7ec4dedb2f5fa739f0a427fcaf514ec19373dd354f2e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.
|
1
|
+
4.0.6
|
data/lib/kumo_keisei/stack.rb
CHANGED
@@ -13,11 +13,14 @@ module KumoKeisei
|
|
13
13
|
]
|
14
14
|
|
15
15
|
RECOVERABLE_STATUSES = [
|
16
|
-
'DELETE_COMPLETE',
|
17
16
|
'ROLLBACK_COMPLETE',
|
18
17
|
'ROLLBACK_FAILED'
|
19
18
|
]
|
20
19
|
|
20
|
+
TERMINATED_STATUSES = [
|
21
|
+
'DELETE_COMPLETE'
|
22
|
+
]
|
23
|
+
|
21
24
|
UNRECOVERABLE_STATUSES = [
|
22
25
|
'UPDATE_ROLLBACK_FAILED'
|
23
26
|
]
|
@@ -56,7 +59,6 @@ module KumoKeisei
|
|
56
59
|
|
57
60
|
flash_message "Warning! You are about to delete the CloudFormation Stack #{@stack_name}, enter 'yes' to continue."
|
58
61
|
return unless ConsoleJockey.get_confirmation(@confirmation_timeout)
|
59
|
-
|
60
62
|
wait_until_ready(false)
|
61
63
|
ensure_deleted!
|
62
64
|
end
|
@@ -105,9 +107,8 @@ module KumoKeisei
|
|
105
107
|
def ensure_deleted!
|
106
108
|
stack = get_stack
|
107
109
|
return if stack.nil?
|
108
|
-
return if stack.stack_status
|
110
|
+
return if TERMINATED_STATUSES.include? stack.stack_status
|
109
111
|
|
110
|
-
ConsoleJockey.write_line "There's a previous stack called #{@stack_name} that didn't create properly, I'll clean it up for you..."
|
111
112
|
cloudformation.delete_stack(stack_name: @stack_name)
|
112
113
|
cloudformation.wait_until(:stack_delete_complete, stack_name: @stack_name) { |waiter| waiter.delay = @waiter_delay; waiter.max_attempts = @waiter_attempts }
|
113
114
|
end
|
@@ -117,7 +118,14 @@ module KumoKeisei
|
|
117
118
|
return false if stack.nil?
|
118
119
|
|
119
120
|
return true if UPDATEABLE_STATUSES.include? stack.stack_status
|
120
|
-
|
121
|
+
|
122
|
+
return false if TERMINATED_STATUSES.include? stack.stack_status
|
123
|
+
|
124
|
+
if RECOVERABLE_STATUSES.include? stack.stack_status
|
125
|
+
ConsoleJockey.write_line "There's a previous stack called #{@stack_name} that didn't create properly, it will be deleted and rebuilt."
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
|
121
129
|
raise UpdateError.new("Stack is in an unrecoverable state") if UNRECOVERABLE_STATUSES.include? stack.stack_status
|
122
130
|
raise UpdateError.new("Stack is busy, try again soon")
|
123
131
|
end
|
@@ -15,7 +15,7 @@ describe KumoKeisei::Stack do
|
|
15
15
|
|
16
16
|
let(:stack_timeout_options) do
|
17
17
|
{
|
18
|
-
confirmation_timeout:
|
18
|
+
confirmation_timeout: 1,
|
19
19
|
waiter_delay: 1,
|
20
20
|
waiter_attempts: 90
|
21
21
|
}
|
@@ -76,4 +76,48 @@ describe KumoKeisei::Stack do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
end
|
79
|
+
|
80
|
+
describe "#destroy!" do
|
81
|
+
let(:stack) { KumoKeisei::Stack.new(stack_name, environment_name, stack_timeout_options) }
|
82
|
+
|
83
|
+
subject { stack.destroy! }
|
84
|
+
|
85
|
+
before do
|
86
|
+
# create a sacrificial stack
|
87
|
+
cloudformation = Aws::CloudFormation::Client.new
|
88
|
+
cloudformation.create_stack(
|
89
|
+
stack_name: stack_full_name,
|
90
|
+
template_body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'no-parameter-section.json')),
|
91
|
+
capabilities: ["CAPABILITY_IAM"],
|
92
|
+
on_failure: "DELETE"
|
93
|
+
)
|
94
|
+
begin
|
95
|
+
cloudformation.wait_until(:stack_create_complete, stack_name: stack_full_name) { |waiter| waiter.delay = 1; waiter.max_attempts = 90 }
|
96
|
+
rescue Aws::Waiters::Errors::UnexpectedError => ex
|
97
|
+
handle_unexpected_error(ex)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "when a user accepts the warning" do
|
102
|
+
it "deletes a stack" do
|
103
|
+
expect(STDIN).to receive(:gets).and_return("yes\n")
|
104
|
+
subject
|
105
|
+
expect(stack_exists?(stack_full_name)).to be false
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when a user does not accept the warning" do
|
110
|
+
it "does not delete a stack because of timeout" do
|
111
|
+
subject
|
112
|
+
expect(stack_exists?(stack_full_name)).to be true
|
113
|
+
end
|
114
|
+
|
115
|
+
it "does not delete a stack because the user didn't say 'yes'" do
|
116
|
+
expect(STDIN).to receive(:gets).and_return("trolololo\n")
|
117
|
+
subject
|
118
|
+
expect(stack_exists?(stack_full_name)).to be true
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
79
123
|
end
|
@@ -8,12 +8,12 @@ describe KumoKeisei::ConsoleJockey do
|
|
8
8
|
context 'no timeout' do
|
9
9
|
|
10
10
|
it 'returns true if user enters yes' do
|
11
|
-
allow(STDIN).to receive(:gets) { 'yes'}
|
11
|
+
allow(STDIN).to receive(:gets) { 'yes' }
|
12
12
|
expect(subject.get_confirmation(timeout)).to be true
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'returns false if user enters anything other than yes' do
|
16
|
-
allow(STDIN).to receive(:gets) { 'aoisdjofa'}
|
16
|
+
allow(STDIN).to receive(:gets) { 'aoisdjofa' }
|
17
17
|
expect(subject.get_confirmation).to be false
|
18
18
|
end
|
19
19
|
end
|
@@ -43,7 +43,6 @@ describe KumoKeisei::Stack do
|
|
43
43
|
|
44
44
|
before do
|
45
45
|
allow(KumoKeisei::ConsoleJockey).to receive(:flash_message)
|
46
|
-
allow(KumoKeisei::ConsoleJockey).to receive(:write_line).and_return(nil)
|
47
46
|
allow(KumoKeisei::ConsoleJockey).to receive(:get_confirmation).with(confirmation_timeout).and_return(false)
|
48
47
|
allow(Aws::CloudFormation::Client).to receive(:new).and_return(cloudformation)
|
49
48
|
allow(cloudformation).to receive(:describe_stacks).with({stack_name: stack_name}).and_return(cf_stack)
|
@@ -59,11 +58,20 @@ describe KumoKeisei::Stack do
|
|
59
58
|
subject.destroy!
|
60
59
|
end
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
context "and the user confirms" do
|
62
|
+
it "deletes the stack" do
|
63
|
+
expect(KumoKeisei::ConsoleJockey).to receive(:get_confirmation).with(confirmation_timeout).and_return(true)
|
64
|
+
expect(cloudformation).to receive(:delete_stack).with({stack_name: stack_name}).and_return(cf_stack)
|
65
|
+
allow(cloudformation).to receive(:wait_until).with(:stack_delete_complete, stack_name: stack_name).and_return(nil)
|
66
|
+
subject.destroy!
|
67
|
+
end
|
68
|
+
|
69
|
+
it "does not print a misleading message" do
|
70
|
+
expect(KumoKeisei::ConsoleJockey).to receive(:get_confirmation).with(confirmation_timeout).and_return(true)
|
71
|
+
expect(cloudformation).to receive(:delete_stack).with({stack_name: stack_name}).and_return(cf_stack)
|
72
|
+
allow(cloudformation).to receive(:wait_until).with(:stack_delete_complete, stack_name: stack_name).and_return(nil)
|
73
|
+
expect { subject.destroy! }.not_to output.to_stdout
|
74
|
+
end
|
67
75
|
end
|
68
76
|
|
69
77
|
it "does not delete the stack if the the user refuses confirmation" do
|
@@ -74,6 +82,11 @@ describe KumoKeisei::Stack do
|
|
74
82
|
end
|
75
83
|
|
76
84
|
describe "#apply!" do
|
85
|
+
|
86
|
+
before do
|
87
|
+
allow(KumoKeisei::ConsoleJockey).to receive(:write_line).and_return(nil)
|
88
|
+
end
|
89
|
+
|
77
90
|
context "when you don't specify the location of the Cfn template" do
|
78
91
|
let(:stack_config) {
|
79
92
|
{
|
@@ -191,6 +204,7 @@ describe KumoKeisei::Stack do
|
|
191
204
|
|
192
205
|
allow(cloudformation).to receive(:wait_until).with(:stack_create_complete, stack_name: stack_name).and_return(nil)
|
193
206
|
|
207
|
+
expect(KumoKeisei::ConsoleJockey).to receive(:write_line).with("There's a previous stack called my-stack-non-production that didn't create properly, it will be deleted and rebuilt.").and_return(nil)
|
194
208
|
subject.apply!(stack_config)
|
195
209
|
end
|
196
210
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumo_keisei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Redbubble
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.2.2
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: A collection of utilities for dealing with AWS Cloud Formation.
|