ironfan 4.9.4 → 4.9.5

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v4.9.5
2
+ * generalizing tell_you_thrice from ec2/machine
3
+ * cleaner message in rescue of tell_you_thrice
4
+
1
5
  # v4.9.4
2
6
  * ec2/machine: fixing debug output (duh)
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.9.4
1
+ 4.9.5
data/ironfan.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ironfan"
8
- s.version = "4.9.4"
8
+ s.version = "4.9.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Infochimps"]
@@ -170,20 +170,11 @@ module Ironfan
170
170
  computer.machine = machine
171
171
  remember machine, :id => computer.name
172
172
 
173
- # Trying a more brute force "I tell you 3 times", to get around
174
- # https://github.com/infochimps-labs/ironfan/issues/271
175
173
  Ironfan.step(fog_server.id,"waiting for machine to be ready", :gray)
176
- begin
174
+ Ironfan.tell_you_thrice :name => fog_server.id,
175
+ :problem => "server unavailable",
176
+ :error_class => Fog::Errors::Error do
177
177
  fog_server.wait_for { ready? }
178
- rescue Fog::Errors::Error => e
179
- try ||= 0
180
- raise if try > 3
181
- try += 1
182
- pause_for = 3 * try
183
- Ironfan.step(fog_server.id,"rescue ##{try}, sleeping #{pause_for} seconds")
184
- Chef::Log.debug "Error was #{e.inspect}"
185
- sleep pause_for
186
- retry
187
178
  end
188
179
  end
189
180
 
data/lib/ironfan.rb CHANGED
@@ -141,6 +141,33 @@ module Ironfan
141
141
  end
142
142
  end
143
143
 
144
+ #
145
+ # Utility to retry a flaky operation three times, with ascending wait times
146
+ #
147
+ def self.tell_you_thrice(options={})
148
+ options = { name: "problem",
149
+ problem: nil,
150
+ error_class: StandardError,
151
+ retries: 3,
152
+ multiplier: 3 }.merge!(options)
153
+ try = 0
154
+ message = ''
155
+
156
+ begin
157
+ yield
158
+ rescue error_class => err
159
+ raise if try > retries
160
+ try += 1
161
+ pause_for = multiplier * try
162
+ message += "#{problem}, " unless problem.nil?
163
+ message += "sleeping #{pause_for} seconds"
164
+ Ironfan.step(name, message, :gray)
165
+ Chef::Log.debug "Error was #{err.inspect}"
166
+ sleep pause_for
167
+ retry
168
+ end
169
+ end
170
+
144
171
  #
145
172
  # Utility to show a step of the overall process
146
173
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ironfan
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.9.4
4
+ version: 4.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -359,7 +359,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
359
359
  version: '0'
360
360
  segments:
361
361
  - 0
362
- hash: -2624176669841722455
362
+ hash: -484279386276054459
363
363
  required_rubygems_version: !ruby/object:Gem::Requirement
364
364
  none: false
365
365
  requirements: