olery-aws 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/console +7 -0
- data/lib/olery/aws/command/rotate.rb +40 -18
- data/lib/olery/aws/version.rb +1 -1
- data/lib/olery/aws.rb +1 -0
- data/olery-aws.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac29fe4f4188601f1e6c5448b1559342f715ff959dfdd383416c515ede4b4136
|
4
|
+
data.tar.gz: 48b99d784fae2a65b917f5d938704228b8174fb607b7a981e3ba290c0da253e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438cb9bf859d8aca981836eda06b8b659df66c157dc3bdb16f341f19ee709e4070f82d3f2492aff09c411ab7dfaa11a249937a830cc2231d861aaf1ff77ebf37
|
7
|
+
data.tar.gz: 49c2c42bbd65b3df9b7808b32050bcd068e6f2bb340b5bada16453f32ace09ea1d7f207cbb1837e3bbbf67d11694884f50bfc0fd66e3925a86e3e77b94224293
|
data/bin/console
ADDED
@@ -102,15 +102,23 @@ Examples:
|
|
102
102
|
# @param [Struct] group
|
103
103
|
#
|
104
104
|
def rotate_elb(group)
|
105
|
-
|
105
|
+
if group.load_balancer_names.blank?
|
106
|
+
info 'Starting instance refresh'
|
107
|
+
auto_scaling.start_instance_refresh auto_scaling_group_name: group.auto_scaling_group_name
|
106
108
|
|
107
|
-
|
109
|
+
info 'Waiting refresh to finish'
|
110
|
+
wait_until_refresh group
|
111
|
+
return
|
112
|
+
end
|
108
113
|
|
109
|
-
|
110
|
-
|
114
|
+
info 'Disabling terminating of instances'
|
115
|
+
suspend_processes group.auto_scaling_group_name, 'Terminate'
|
111
116
|
|
112
|
-
|
117
|
+
new_size = group.max_size * 2
|
118
|
+
new_desired = group.desired_capacity * 2
|
119
|
+
instance_ids = group.instances.map(&:instance_id)
|
113
120
|
|
121
|
+
info "Doubling autoscaling desired to #{new_desired} and capacity to #{new_size}"
|
114
122
|
update_group(
|
115
123
|
group.auto_scaling_group_name,
|
116
124
|
max_size: new_size,
|
@@ -118,34 +126,26 @@ Examples:
|
|
118
126
|
)
|
119
127
|
|
120
128
|
info 'Waiting for ELBs to register instances'
|
121
|
-
|
122
|
-
wait_for_elbs group.load_balancer_names, new_desired
|
129
|
+
wait_for_elbs group, new_desired
|
123
130
|
|
124
131
|
info 'Waiting for all instances to be in service'
|
125
|
-
|
126
132
|
group.load_balancer_names.each do |elb_name|
|
127
133
|
wait_until_in_service(elb_name)
|
128
134
|
end
|
129
135
|
|
130
|
-
instance_ids = group.instances.map(&:instance_id)
|
131
|
-
|
132
136
|
info 'Disabling launching of new instances'
|
133
|
-
|
134
137
|
suspend_processes(group.auto_scaling_group_name, 'Launch')
|
135
138
|
|
136
139
|
info 'Detaching old instances'
|
137
|
-
|
138
140
|
detach_instances(group.auto_scaling_group_name, instance_ids)
|
139
141
|
|
140
142
|
info 'Waiting for instances to be removed from autoscaling group'
|
141
|
-
|
142
143
|
wait_until_removed_from_group(
|
143
144
|
group.auto_scaling_group_name,
|
144
145
|
instance_ids
|
145
146
|
)
|
146
147
|
|
147
148
|
info 'Terminating old instances'
|
148
|
-
|
149
149
|
terminate_instances(instance_ids)
|
150
150
|
|
151
151
|
wait_until_terminated(instance_ids)
|
@@ -302,22 +302,44 @@ Examples:
|
|
302
302
|
# @param [Array] elb_names
|
303
303
|
# @param [Struct] group
|
304
304
|
#
|
305
|
-
def wait_for_elbs
|
305
|
+
def wait_for_elbs group, instances
|
306
306
|
loop_with_limit do
|
307
307
|
response = load_balancing.describe_load_balancers(
|
308
|
-
:load_balancer_names =>
|
308
|
+
:load_balancer_names => group.load_balancer_names
|
309
309
|
)
|
310
310
|
|
311
311
|
ok_elbs = response.load_balancer_descriptions.count do |elb|
|
312
312
|
elb.instances.length == instances
|
313
313
|
end
|
314
314
|
|
315
|
-
break if ok_elbs ==
|
315
|
+
break if ok_elbs == group.load_balancer_names.length
|
316
316
|
|
317
317
|
sleep(5)
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
def wait_until_refresh group
|
322
|
+
loop_with_limit do
|
323
|
+
desc = auto_scaling.describe_instance_refreshes auto_scaling_group_name: group.auto_scaling_group_name
|
324
|
+
refresh = desc.instance_refreshes.first
|
325
|
+
|
326
|
+
break if refresh.percentage_complete == 100
|
327
|
+
|
328
|
+
sleep 10
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def wait_until_healthy group, desired
|
333
|
+
loop_with_limit do
|
334
|
+
group = get_group group.auto_scaling_group_name
|
335
|
+
|
336
|
+
instances = group.instances.select{ |i| lifecycle_state == 'InService' and g.health_status == 'Healthy' }
|
337
|
+
break if instances.size == desired
|
338
|
+
|
339
|
+
sleep 5
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
321
343
|
##
|
322
344
|
# @param [String] elb_name
|
323
345
|
#
|
@@ -463,7 +485,7 @@ Examples:
|
|
463
485
|
# @return [String|NilClass]
|
464
486
|
#
|
465
487
|
def group_locked_by(group_name)
|
466
|
-
tag = get_group(group_name).tags.find
|
488
|
+
tag = get_group(group_name).tags.find{ |t| t.key == LOCK_TAG }
|
467
489
|
|
468
490
|
tag ? tag.value : nil
|
469
491
|
end
|
data/lib/olery/aws/version.rb
CHANGED
data/lib/olery/aws.rb
CHANGED
data/olery-aws.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_dependency 'aws-sdk', '~> 2.0'
|
23
23
|
gem.add_dependency 'slop', '~> 4.0'
|
24
24
|
gem.add_dependency 'uuid'
|
25
|
+
gem.add_dependency 'activesupport'
|
25
26
|
|
26
27
|
gem.add_development_dependency 'pry'
|
27
28
|
gem.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: olery-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olery B.V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +131,7 @@ extensions: []
|
|
117
131
|
extra_rdoc_files: []
|
118
132
|
files:
|
119
133
|
- README.md
|
134
|
+
- bin/console
|
120
135
|
- bin/olery-aws
|
121
136
|
- lib/olery/aws.rb
|
122
137
|
- lib/olery/aws/command.rb
|