stemcell 0.11.9 → 0.11.10

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
  SHA1:
3
- metadata.gz: 4d3d71d194f64fa371f8052946dd96ce7d014434
4
- data.tar.gz: e25f56378baeeaee5e5750fb74fc938db759c2d4
3
+ metadata.gz: 7507325651ec8da0572ef5638823edc4250ba9c7
4
+ data.tar.gz: 5141fb0f5d90116e1245a233193d144af1b7bb4a
5
5
  SHA512:
6
- metadata.gz: ad7f8d3f4343e2c98591339cda7f6351d25aac7648e54c7a4f6d46e23264fefeb704e74a4d69bbdb7cc67f12f0fcefdf44d69c43db1728a35f3850592a4408b8
7
- data.tar.gz: 253d9789fe346065cb9a4911e6806a0a60a3a2ccd3161fd9452b307ff57f1c54d3a9daa5bb97e54c1ceb8bc4c5c7eefc6b5e12e208e42e56a4518fe2c05241c5
6
+ metadata.gz: 02625b23aeefca813c24cdbba7c7886f15f9294938ff78b5b0fcacd599e2404e751db09c414750e29f1b533e13f0997a4abea5535c4d0e9d6d69f0df3e1541a6
7
+ data.tar.gz: 14009ac687b05b8b8eb931d62b2593ebfcf4eefe0c61f6ab00f156580c8a3e830d3e8bb87e4ac6b0fd1a102f74c396ef15ec16c071463be504edb90d20dc059d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.11.10
2
+ - Configurable number of retries for batch operations
3
+ - Do not set set_classic_link on vpc instances
4
+
1
5
  # 0.11.9
2
6
  - Transform chef_cookbook_attributes option for command-line parser
3
7
  - Set vpc_id when creating Launcher object
@@ -78,6 +78,7 @@ module Stemcell
78
78
  @aws_access_key = opts['aws_access_key']
79
79
  @aws_secret_key = opts['aws_secret_key']
80
80
  @aws_session_token = opts['aws_session_token']
81
+ @max_attempts = opts['max_attempts'] || 3
81
82
  configure_aws_creds_and_region
82
83
  end
83
84
 
@@ -194,8 +195,10 @@ module Stemcell
194
195
  @log.info "sent ec2 api tag requests successfully"
195
196
 
196
197
  # link to classiclink
197
- set_classic_link(instances, opts['classic_link'])
198
- @log.info "successfully applied classic link settings (if any)"
198
+ if @vpc_id.nil?
199
+ set_classic_link(instances, opts['classic_link'])
200
+ @log.info "successfully applied classic link settings (if any)"
201
+ end
199
202
 
200
203
  # turn on termination protection
201
204
  # we do this now to make sure all other settings worked
@@ -391,7 +394,6 @@ module Stemcell
391
394
  File.read(File.expand_path(opt)) rescue opt
392
395
  end
393
396
 
394
- MAX_ATTEMPTS = 3
395
397
  INITIAL_RETRY_SEC = 1
396
398
 
397
399
  # Return a Hash of instance => error. Empty hash indicates "no error"
@@ -404,7 +406,7 @@ module Stemcell
404
406
  begin
405
407
  attempt = 0
406
408
  result = nil
407
- while attempt < MAX_ATTEMPTS
409
+ while attempt < @max_attempts
408
410
  # sleep idempotently except for the first attempt
409
411
  sleep(INITIAL_RETRY_SEC * 2 ** attempt) if attempt != 0
410
412
  result = yield(instance)
@@ -100,6 +100,7 @@ module Stemcell
100
100
  'aws_session_token' => options['aws_session_token'],
101
101
  'region' => options['region'],
102
102
  'vpc_id' => options['vpc_id'],
103
+ 'max_attempts' => options['batch_operation_retries'],
103
104
  })
104
105
  # Slice off just the options used for launching.
105
106
  launch_options = {}
@@ -291,7 +291,15 @@ module Stemcell
291
291
  :desc => "comma-separated list of contexts to override certain values",
292
292
  :type => String,
293
293
  :env => "CONTEXTS",
294
- }
294
+ },
295
+ {
296
+ :name => 'batch_operation_retries',
297
+ :desc => "maximum number of retries",
298
+ :type => Integer,
299
+ :env => 'BATCH_OPERATION_RETRIES',
300
+ :short => :r,
301
+ :default => 3,
302
+ },
295
303
  ]
296
304
 
297
305
  def initialize(config={})
@@ -1,3 +1,3 @@
1
1
  module Stemcell
2
- VERSION = "0.11.9"
2
+ VERSION = "0.11.10"
3
3
  end
@@ -86,6 +86,8 @@ describe Stemcell::Launcher do
86
86
  :user_data => 'template'
87
87
  )).and_return(instances)
88
88
  expect(launcher).to receive(:set_tags).with(kind_of(Array), kind_of(Hash)).and_return(nil)
89
+ # set_classic_link should not be set on vpc hosts.
90
+ expect(launcher).not_to receive(:set_classic_link)
89
91
 
90
92
  launcher.send(:launch, launch_options)
91
93
  end
@@ -155,6 +157,24 @@ describe Stemcell::Launcher do
155
157
  end
156
158
  expect(errors.all?(&:nil?)).to be true
157
159
  end
160
+
161
+ it "retries up to max_attempts option per instance" do
162
+ max_attempts = 6
163
+ opts = {'region' => 'region', 'max_attempts' => max_attempts}
164
+ launcher = Stemcell::Launcher.new(opts)
165
+ allow(launcher).to receive(:sleep).and_return(0)
166
+ tags = double("Tags")
167
+ instances = (1..2).map do |id|
168
+ inst = MockInstance.new(id)
169
+ allow(inst).to receive(:tags).and_return(tags)
170
+ inst
171
+ end
172
+ expect(tags).to receive(:set).with({'a' => 'b'}).exactly(12).times.
173
+ and_raise(AWS::EC2::Errors::InvalidInstanceID::NotFound.new("error"))
174
+ expect do
175
+ launcher.send(:set_tags, instances, {'a' => 'b'})
176
+ end.to raise_error(Stemcell::IncompleteOperation)
177
+ end
158
178
  end
159
179
 
160
180
  describe '#configure_aws_creds_and_region' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stemcell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.9
4
+ version: 0.11.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Rhoads
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-01-25 00:00:00.000000000 Z
14
+ date: 2018-02-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: aws-sdk-v1
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  requirements: []
243
243
  rubyforge_project:
244
- rubygems_version: 2.5.2
244
+ rubygems_version: 2.6.13
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: no summary