bosh_aws_cpi 1.2559.0 → 1.2560.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,18 +43,7 @@ module Bosh::AwsCloud
43
43
  spot_instance_requests = @region.client.request_spot_instances(spot_request_spec)
44
44
  @logger.debug("Got spot instance requests: #{spot_instance_requests.inspect}")
45
45
 
46
- Bosh::Common.retryable(sleep: instance_create_wait_time*2, tries: 20) do |tries, error|
47
- @logger.debug("Checking state of spot instance requests...")
48
- spot_instance_request_ids = spot_instance_requests[:spot_instance_request_set].map { |r| r[:spot_instance_request_id] }
49
- response = @region.client.describe_spot_instance_requests(:spot_instance_request_ids => spot_instance_request_ids)
50
- statuses = response[:spot_instance_request_set].map { |rr| rr[:state] }
51
- @logger.debug("Spot instance request states: #{statuses.inspect}")
52
- if statuses.all? { |s| s == 'active' }
53
- @logger.info("Spot request instances fulfilled: #{response.inspect}")
54
- instance_id = response[:spot_instance_request_set].map { |rr| rr[:instance_id] }[0]
55
- @instance = @region.instances[instance_id]
56
- end
57
- end
46
+ wait_for_spot_instance_request_to_be_active spot_instance_requests
58
47
  else
59
48
  # Retry the create instance operation a couple of times if we are told that the IP
60
49
  # address is in use - it can happen when the director recreates a VM and AWS
@@ -111,6 +100,26 @@ module Bosh::AwsCloud
111
100
  }
112
101
  end
113
102
 
103
+ def wait_for_spot_instance_request_to_be_active(spot_instance_requests)
104
+ # Query the spot request state until it becomes "active".
105
+ # This can result in the errors listed below; this is normally because AWS has
106
+ # been slow to update its state so the correct response is to wait a bit and try again.
107
+ errors = [AWS::EC2::Errors::InvalidSpotInstanceRequestID::NotFound]
108
+ Bosh::Common.retryable(sleep: instance_create_wait_time*2, tries: 20, on: errors) do |tries, error|
109
+ @logger.warn("Retrying after expected error: #{error}") if error
110
+ @logger.debug("Checking state of spot instance requests...")
111
+ spot_instance_request_ids = spot_instance_requests[:spot_instance_request_set].map { |r| r[:spot_instance_request_id] }
112
+ response = @region.client.describe_spot_instance_requests(:spot_instance_request_ids => spot_instance_request_ids)
113
+ statuses = response[:spot_instance_request_set].map { |rr| rr[:state] }
114
+ @logger.debug("Spot instance request states: #{statuses.inspect}")
115
+ if statuses.all? { |s| s == 'active' }
116
+ @logger.info("Spot request instances fulfilled: #{response.inspect}")
117
+ instance_id = response[:spot_instance_request_set].map { |rr| rr[:instance_id] }[0]
118
+ @instance = @region.instances[instance_id]
119
+ end
120
+ end
121
+ end
122
+
114
123
  def terminate(instance_id, fast=false)
115
124
  @instance = @region.instances[instance_id]
116
125
 
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module AwsCloud
3
- VERSION = '1.2559.0'
3
+ VERSION = '1.2560.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_aws_cpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2559.0
4
+ version: 1.2560.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-15 00:00:00.000000000 Z
12
+ date: 2014-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.2559.0
37
+ version: 1.2560.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.2559.0
45
+ version: 1.2560.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bosh_cpi
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 1.2559.0
53
+ version: 1.2560.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2559.0
61
+ version: 1.2560.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh-registry
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 1.2559.0
69
+ version: 1.2560.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.2559.0
77
+ version: 1.2560.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: httpclient
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: 0.8.2
110
110
  description: ! 'BOSH AWS CPI
111
111
 
112
- 664e0d'
112
+ 2bb07f'
113
113
  email: support@cloudfoundry.com
114
114
  executables:
115
115
  - bosh_aws_console
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  segments:
161
161
  - 0
162
- hash: 1836125855612603795
162
+ hash: -271901431206060787
163
163
  requirements: []
164
164
  rubyforge_project:
165
165
  rubygems_version: 1.8.23