bosh_aws_cpi 1.5.0.pre.1504 → 1.5.0.pre.1525
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cloud/aws/resource_wait.rb +18 -18
- data/lib/cloud/aws/version.rb +1 -1
- metadata +9 -9
@@ -4,8 +4,10 @@ module Bosh::AwsCloud
|
|
4
4
|
class ResourceWait
|
5
5
|
include Helpers
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
# a sane amount of retries on AWS (~25 minutes),
|
8
|
+
# as things can take anywhere between a minute and forever
|
9
|
+
DEFAULT_TRIES = 54
|
10
|
+
MAX_SLEEP_EXPONENT = 5
|
9
11
|
|
10
12
|
def self.for_instance(args)
|
11
13
|
raise ArgumentError, "args should be a Hash, but `#{args.class}' given" unless args.is_a?(Hash)
|
@@ -128,6 +130,15 @@ module Bosh::AwsCloud
|
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
133
|
+
def self.sleep_callback(description, tries)
|
134
|
+
lambda do |num_tries, error|
|
135
|
+
sleep_time = 2**[num_tries, MAX_SLEEP_EXPONENT].min # Exp backoff: 1, 2, 4, 8 ... up to max 32
|
136
|
+
Bosh::AwsCloud::ResourceWait.logger.debug("#{error.class}: `#{error.message}'") if error
|
137
|
+
Bosh::AwsCloud::ResourceWait.logger.debug("#{description}, retrying in #{sleep_time} seconds (#{num_tries}/#{tries})")
|
138
|
+
sleep_time
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
131
142
|
def self.logger
|
132
143
|
Bosh::Clouds::Config.logger
|
133
144
|
end
|
@@ -140,7 +151,7 @@ module Bosh::AwsCloud
|
|
140
151
|
@started_at = Time.now
|
141
152
|
end
|
142
153
|
|
143
|
-
def for_resource(args)
|
154
|
+
def for_resource(args, &blk)
|
144
155
|
resource = args.fetch(:resource)
|
145
156
|
state_method = args.fetch(:state_method, :status)
|
146
157
|
errors = args.fetch(:errors, [])
|
@@ -155,39 +166,28 @@ module Bosh::AwsCloud
|
|
155
166
|
end
|
156
167
|
|
157
168
|
state = nil
|
158
|
-
Bosh::
|
169
|
+
Bosh::Retryable.new(tries: tries, sleep: sleep_cb, on: errors, ensure: ensure_cb).retryer do
|
159
170
|
Bosh::AwsCloud::ResourceWait.task_checkpoint
|
160
171
|
|
161
172
|
state = resource.method(state_method).call
|
162
|
-
|
163
173
|
if state == :error || state == :failed
|
164
174
|
raise Bosh::Clouds::CloudError, "#{desc} state is #{state}, expected #{target_state}, took #{time_passed}s"
|
165
175
|
end
|
166
176
|
|
167
177
|
# the yielded block should return true if we have reached the target state
|
168
|
-
|
178
|
+
blk.call(state)
|
169
179
|
end
|
170
180
|
|
171
181
|
Bosh::AwsCloud::ResourceWait.logger.info("#{desc} is now #{state}, took #{time_passed}s")
|
172
182
|
rescue Bosh::Common::RetryCountExceeded => e
|
173
|
-
Bosh::AwsCloud::ResourceWait.logger.error(
|
183
|
+
Bosh::AwsCloud::ResourceWait.logger.error(
|
184
|
+
"Timed out waiting for #{desc} state is #{state}, expected to be #{target_state}, took #{time_passed}s")
|
174
185
|
raise e
|
175
186
|
end
|
176
187
|
|
177
188
|
def time_passed
|
178
189
|
Time.now - @started_at
|
179
190
|
end
|
180
|
-
|
181
|
-
private
|
182
|
-
|
183
|
-
def self.sleep_callback(description, tries)
|
184
|
-
lambda do |num_tries, error|
|
185
|
-
sleep_time = 2**[num_tries, MAX_SLEEP_EXPONENT].min # Exp backoff: 1, 2, 4, 8 ... up to max 256
|
186
|
-
Bosh::AwsCloud::ResourceWait.logger.debug("#{error.class}: `#{error.message}'") if error
|
187
|
-
Bosh::AwsCloud::ResourceWait.logger.debug("#{description}, retrying in #{sleep_time} seconds (#{num_tries}/#{tries})")
|
188
|
-
sleep_time
|
189
|
-
end
|
190
|
-
end
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
data/lib/cloud/aws/version.rb
CHANGED
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.5.0.pre.
|
4
|
+
version: 1.5.0.pre.1525
|
5
5
|
prerelease: 6
|
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: 2013-12-
|
12
|
+
date: 2013-12-10 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.5.0.pre.
|
37
|
+
version: 1.5.0.pre.1525
|
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.5.0.pre.
|
45
|
+
version: 1.5.0.pre.1525
|
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.5.0.pre.
|
53
|
+
version: 1.5.0.pre.1525
|
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.5.0.pre.
|
61
|
+
version: 1.5.0.pre.1525
|
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.5.0.pre.
|
69
|
+
version: 1.5.0.pre.1525
|
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.5.0.pre.
|
77
|
+
version: 1.5.0.pre.1525
|
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
|
-
|
112
|
+
df3988'
|
113
113
|
email: support@cloudfoundry.com
|
114
114
|
executables:
|
115
115
|
- bosh_aws_console
|