aerosol 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c51be45f1098f15a79cbab049755110bf351bed1661bb5b28504ab34c613f01
4
- data.tar.gz: 235972faf898d0cc796cdf0b7de74f05a6c3aa396dc13b9f0f8909fb1229cecb
3
+ metadata.gz: 9494ad62c369aa73f67af3dca0dcc28d8dd29ef820e5bd75c05e30b4203bd950
4
+ data.tar.gz: a7be58f47b1d874751346371cc3e448bcea64f5fce4846fc2b2c4875788db5ee
5
5
  SHA512:
6
- metadata.gz: 5aa215e96061f829d5042d72c56495f0059cb716b12b89386ca84e7b5568b6993d39a18d07e216c90de2af96ba742d5ea588c733e0303d275ffdb16bfb7f8965
7
- data.tar.gz: 890ced1dce45bcf8ab1de6d60834f78bd881490efd9d7473ada54ac92359a691c53f031959c9cb7e08fb1745c7d9ada0abb84b00913d83e5166cb661c252fdbd
6
+ metadata.gz: 805b520c8b7e883e58113b864732bbd841f01d56d3d1703da8e79982d940d590a47d0f2ed5458efa523bbb03c95d81a82eee5b031d81f946f92d7ff58b1f6024
7
+ data.tar.gz: 8b0390907ccbefef4e58d333f2e92da0a5489304380776fa00836fa9d578200c1623a489985aa1bff66e48e22cea84cdbcec2915ad984b1d364e0fcf31955b9d
@@ -41,7 +41,7 @@ class Aerosol::AutoScaling
41
41
  def create!
42
42
  ensure_present! :max_size, :min_size
43
43
  raise 'availability_zones or vpc_zone_identifier must be set' if [availability_zones, vpc_zone_identifier].none?
44
- raise 'launch_configuration or launch_template must be set' if [launch_configuration, launch_template].none?
44
+ raise 'launch_configuration or launch_template must be set' unless launch_details
45
45
 
46
46
  info "creating auto scaling group"
47
47
  launch_details = create_launch_details
@@ -70,9 +70,9 @@ class Aerosol::AutoScaling
70
70
  conn.delete_auto_scaling_group(auto_scaling_group_name: auto_scaling_group_name, force_delete: true)
71
71
  begin
72
72
  (0..2).each { break if deleting?; sleep 1 }
73
- launch_configuration.destroy
73
+ launch_details.destroy
74
74
  rescue => ex
75
- info "Launch Config: #{launch_configuration} for #{auto_scaling_group_name} was not deleted."
75
+ info "Launch Details: #{launch_details} for #{auto_scaling_group_name} were not deleted."
76
76
  info ex.message
77
77
  end
78
78
  end
@@ -91,6 +91,10 @@ class Aerosol::AutoScaling
91
91
  .instances.map { |instance| Aerosol::Instance.from_hash(instance) }
92
92
  end
93
93
 
94
+ def launch_details
95
+ launch_configuration || launch_template
96
+ end
97
+
94
98
  def tag(val)
95
99
  tags.merge!(val)
96
100
  end
@@ -152,6 +156,12 @@ class Aerosol::AutoScaling
152
156
  }}
153
157
  end
154
158
 
159
+ def self.from_hash(hash)
160
+ instance = super(hash)
161
+ instance['launch_template'] = (hash[:launch_template][:launch_template_name]) if hash[:launch_template]
162
+ instance
163
+ end
164
+
155
165
  private
156
166
  def conn
157
167
  Aerosol::AWS.auto_scaling
@@ -5,6 +5,7 @@ class Aerosol::Instance
5
5
 
6
6
  aws_attribute :availability_zone, :health_status, :instance_id, :lifecycle_state
7
7
  aws_class_attribute :launch_configuration, Aerosol::LaunchConfiguration
8
+ aws_class_attribute :launch_template, Aerosol::LaunchTemplate
8
9
  primary_key :instance_id
9
10
 
10
11
  def live?
@@ -58,6 +59,12 @@ class Aerosol::Instance
58
59
  instances
59
60
  end
60
61
 
62
+ def self.from_hash(hash)
63
+ instance = super(hash)
64
+ instance['launch_template'] = (hash[:launch_template][:launch_template_name]) if hash[:launch_template]
65
+ instance
66
+ end
67
+
61
68
  private
62
69
  def describe!
63
70
  ensure_present! :instance_id
@@ -60,7 +60,7 @@ class Aerosol::LaunchTemplate
60
60
  def all_instances
61
61
  Aerosol::Instance.all.select { |instance|
62
62
  !instance.launch_template.nil? &&
63
- (instance.launch_template.launch_template == launch_template_name)
63
+ (instance.launch_template == launch_template_name)
64
64
  }.each(&:description)
65
65
  end
66
66
 
@@ -229,7 +229,7 @@ class Aerosol::Runner
229
229
 
230
230
  def old_instances
231
231
  require_deploy!
232
- old_auto_scaling_groups.map(&:launch_configuration).compact.map(&:all_instances).flatten.compact
232
+ old_auto_scaling_groups.map(&:launch_details).compact.map(&:all_instances).flatten.compact
233
233
  end
234
234
 
235
235
  def old_auto_scaling_groups
@@ -243,6 +243,7 @@ class Aerosol::Runner
243
243
  def select_auto_scaling_groups(&block)
244
244
  require_deploy!
245
245
  Aerosol::LaunchConfiguration.all # load all of the launch configurations first
246
+ Aerosol::LaunchTemplate.all
246
247
  Aerosol::AutoScaling.all.select { |asg|
247
248
  (asg.tags['Deploy'].to_s == auto_scaling.tags['Deploy']) &&
248
249
  (block.nil? ? true : block.call(asg))
@@ -251,11 +252,13 @@ class Aerosol::Runner
251
252
 
252
253
  def new_instances
253
254
  require_deploy!
254
- while launch_configuration.all_instances.length < auto_scaling.min_size
255
+
256
+ while launch_details.all_instances.length < auto_scaling.min_size
255
257
  info "Waiting for instances to come up"
256
258
  sleep 10
257
259
  end
258
- launch_configuration.all_instances
260
+
261
+ launch_details.all_instances
259
262
  end
260
263
 
261
264
  def with_deploy(name)
@@ -280,7 +283,7 @@ class Aerosol::Runner
280
283
  :live_check, :db_config_path, :instance_live_grace_period,
281
284
  :app_port, :continue_if_stop_app_fails, :stop_app_retries,
282
285
  :is_alive?, :log_files, :tail_logs, :to => :deploy
283
- delegate :launch_configuration, :to => :auto_scaling
286
+ delegate :launch_details, :to => :auto_scaling
284
287
 
285
288
  private
286
289
 
@@ -1,5 +1,5 @@
1
1
  # Copyright Swipely, Inc. All rights reserved.
2
2
 
3
3
  module Aerosol
4
- VERSION = '1.9.0'
4
+ VERSION = '1.9.1'
5
5
  end
@@ -253,6 +253,57 @@ describe Aerosol::Runner do
253
253
  end
254
254
 
255
255
  describe '#new_instances' do
256
+ context 'With a launch template' do
257
+ let!(:lt) do
258
+ Aerosol::LaunchTemplate.new! do
259
+ name :lt
260
+ image_id 'fake-ami-how-scandalous'
261
+ instance_type 'm1.large'
262
+ end
263
+ end
264
+ let!(:asg_lt) do
265
+ Aerosol::AutoScaling.new! do
266
+ name :asg_lt
267
+ availability_zones 'us-east-1'
268
+ min_size 0
269
+ max_size 3
270
+ launch_template :lt
271
+ stub(:sleep)
272
+ end
273
+ end
274
+ let!(:instance1) do
275
+ Aerosol::Instance.from_hash(
276
+ {
277
+ instance_id: 'z0',
278
+ launch_template: { launch_template_name: lt.launch_template_name }
279
+ }
280
+ )
281
+ end
282
+ let!(:instance2) do
283
+ double(
284
+ :launch_template => double(:launch_template_name => 'lc7-8891022'),
285
+ :launch_configuration => nil
286
+ )
287
+ end
288
+ let!(:instance3) do
289
+ double(
290
+ :launch_template => nil,
291
+ :launch_configuration => double(:launch_configuration_name => 'lc0-8891022')
292
+ )
293
+ end
294
+
295
+ before do
296
+ Aerosol::Instance.stub(:all).and_return([instance1, instance2, instance3])
297
+ end
298
+
299
+ it 'returns each instance that is a member of the current launch template' do
300
+ deploy = Aerosol::Deploy.new!(name: :lt_deploy, auto_scaling: :asg_lt)
301
+ subject.with_deploy(:lt_deploy) do
302
+ subject.new_instances.should == [instance1]
303
+ end
304
+ end
305
+ end
306
+
256
307
  let!(:lc7) do
257
308
  Aerosol::LaunchConfiguration.new! do
258
309
  name :lc7
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aerosol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-11 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord