right_support 2.6.12 → 2.6.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,11 +83,19 @@ module RightSupport::CI
83
83
  output.puts builder.target!
84
84
  end
85
85
 
86
+ def dump_failure(counter, failure)
87
+ # no-op; our summary contains everything
88
+ end
89
+
90
+ def dump_pending()
91
+ # no-op; our summary contains everything
92
+ end
93
+
86
94
  private
87
95
 
88
96
  def failure_details_for(example)
89
97
  exception = @test_failures[example].exception
90
- exception.nil? ? "" : "#{exception.message}\n#{format_backtrace(exception.backtrace, example).join("\n")}"
98
+ exception.nil? ? "" : "#{exception.message}\n#{format_backtrace(exception.backtrace)}"
91
99
  end
92
100
 
93
101
  def classname_for(example)
@@ -105,7 +105,7 @@ module RightSupport::Net
105
105
  if retries < opts[:retry]
106
106
  retry
107
107
  else
108
- raise e
108
+ raise
109
109
  end
110
110
  end
111
111
  end
@@ -192,7 +192,7 @@ module RightSupport::Net::LB
192
192
  rescue Exception => e
193
193
  t1 = Time.now
194
194
  @stack.increase_state(endpoint, t0, t1)
195
- raise e
195
+ raise
196
196
  end
197
197
 
198
198
  # Proxy to EndpointStack
@@ -74,7 +74,7 @@ module RightSupport::Net::LB
74
74
  rescue Exception => e
75
75
  t1 = Time.now
76
76
  @counter += 1
77
- raise e
77
+ raise
78
78
  end
79
79
 
80
80
  end
@@ -49,7 +49,8 @@ module RightSupport::Net
49
49
  #
50
50
  # A good example of this phenomenon is the rest-client gem, whose base exception
51
51
  # class is derived from RuntimeError!!
52
- DEFAULT_FATAL_EXCEPTIONS = [
52
+ FATAL_RUBY_EXCEPTIONS = [
53
+ # Exceptions that indicate something is seriously wrong with the Ruby VM.
53
54
  NoMemoryError, SystemStackError, SignalException, SystemExit,
54
55
  ScriptError,
55
56
  # Subclasses of StandardError. We can't include the base class directly as
@@ -59,27 +60,34 @@ module RightSupport::Net
59
60
  RegexpError, ThreadError, TypeError, ZeroDivisionError
60
61
  ]
61
62
 
62
- # As a kindness to unit test authors, count RSpec exceptions as fatal. Use some
63
- # reflection to handle ALL RSpec-related exceptions.
64
- spec_namespaces = if require_succeeds?('rspec')
63
+ spec_namespaces = []
64
+
65
+ if require_succeeds?('rspec')
65
66
  # RSpec 2.x
66
- [::RSpec::Mocks, ::RSpec::Expectations]
67
+ spec_namespaces += [::RSpec::Mocks, ::RSpec::Expectations]
67
68
  elsif require_succeeds?('spec')
68
69
  # RSpec 1.x
69
- [::Spec::Expectations]
70
- else
71
- # RSpec is not present
72
- []
70
+ spec_namespaces += [::Spec::Expectations]
73
71
  end
72
+
73
+ # As a kindness to unit test authors, count test-framework exceptions as fatal.
74
+ FATAL_TEST_EXCEPTIONS = []
75
+
76
+ # Use some reflection to locate all RSpec and Test::Unit exceptions
74
77
  spec_namespaces.each do |namespace|
75
78
  namespace.constants.each do |konst|
76
79
  konst = namespace.const_get(konst)
77
80
  if konst.is_a?(Class) && konst.ancestors.include?(Exception)
78
- DEFAULT_FATAL_EXCEPTIONS << konst
81
+ FATAL_TEST_EXCEPTIONS << konst
79
82
  end
80
83
  end
81
84
  end
82
85
 
86
+ # Well-considered exceptions that should count as fatal (non-retryable) by the balancer.
87
+ # Used by default, and if you provide a :fatal option to the balancer, you should probably
88
+ # consult this list in your overridden fatal determination!
89
+ DEFAULT_FATAL_EXCEPTIONS = FATAL_RUBY_EXCEPTIONS + FATAL_TEST_EXCEPTIONS
90
+
83
91
  DEFAULT_FATAL_PROC = lambda do |e|
84
92
  if DEFAULT_FATAL_EXCEPTIONS.any? { |c| e.is_a?(c) }
85
93
  #Some Ruby builtin exceptions indicate program errors
@@ -228,7 +236,13 @@ module RightSupport::Net
228
236
  end
229
237
  rescue Exception => e
230
238
  logger.error "RequestBalancer: health check failed to #{endpoint} because of #{e.class.name}: #{e.message}"
231
- next
239
+ if fatal_exception?(e)
240
+ # Fatal exceptions should still raise, even if only during a health check
241
+ raise
242
+ else
243
+ # Nonfatal exceptions: keep on truckin'
244
+ next
245
+ end
232
246
  end
233
247
 
234
248
  logger.info "RequestBalancer: health check succeeded to #{endpoint}"
@@ -294,32 +308,39 @@ module RightSupport::Net
294
308
  # Decide what to do with an exception. The decision is influenced by the :fatal
295
309
  # option passed to the constructor.
296
310
  def handle_exception(endpoint, e, t0)
297
- fatal = @options[:fatal] || DEFAULT_FATAL_PROC
298
-
299
- #The option may be a proc or lambda; call it to get input
300
- fatal = fatal.call(e) if fatal.respond_to?(:call)
301
-
302
- #The options may be single exception classes, in which case we want to expand
303
- #it out into a list
304
- fatal = [fatal] if fatal.is_a?(Class)
305
-
306
- #The option may be a list of exception classes, in which case we want to evaluate
307
- #whether the exception we're handling is an instance of any mentioned exception
308
- #class
309
- fatal = fatal.any?{ |c| e.is_a?(c) } if fatal.respond_to?(:any?)
311
+ fatal = fatal_exception?(e)
310
312
  duration = sprintf('%.4f', Time.now - t0)
311
- msg = "RequestBalancer: rescued #{fatal ? 'fatal' : 'retryable'} #{e.class.name} during request to #{endpoint}: #{e.message} after #{duration} seconds"
313
+ msg = "RequestBalancer: rescued #{fatal ? 'fatal' : 'retryable'} #{e.class.name} " +
314
+ "during request to #{endpoint}: #{e.message} after #{duration} seconds"
312
315
  logger.error msg
313
316
  @options[:on_exception].call(fatal, e, endpoint) if @options[:on_exception]
314
317
 
315
318
  if fatal
316
- #Final decision: did we identify it as fatal?
317
319
  return e
318
320
  else
319
321
  return nil
320
322
  end
321
323
  end
322
324
 
325
+ def fatal_exception?(e)
326
+ fatal = @options[:fatal] || DEFAULT_FATAL_PROC
327
+
328
+ # We may have a proc or lambda; call it to get dynamic input
329
+ fatal = fatal.call(e) if fatal.respond_to?(:call)
330
+
331
+ # We may have a single exception class, in which case we want to expand
332
+ # it out into a list
333
+ fatal = [fatal] if fatal.is_a?(Class)
334
+
335
+ # We may have a list of exception classes, in which case we want to evaluate
336
+ # whether the exception we're handling is an instance of any mentioned exception
337
+ # class.
338
+ fatal = fatal.any?{ |c| e.is_a?(c) } if fatal.respond_to?(:any?)
339
+
340
+ # Our final decision!
341
+ fatal
342
+ end
343
+
323
344
  def resolve
324
345
  resolved_endpoints = RightSupport::Net::DNS.resolve(@endpoints)
325
346
  logger.info("RequestBalancer: resolved #{@endpoints.inspect} to #{resolved_endpoints.inspect}")
@@ -23,7 +23,7 @@ module RightSupport::Net
23
23
  block.call
24
24
  rescue Exception => e
25
25
  Thread.current[:right_support_net_ssl_expected_hostname] = nil
26
- raise e
26
+ raise
27
27
  ensure
28
28
  Thread.current[:right_support_net_ssl_expected_hostname] = nil
29
29
  end
@@ -61,7 +61,7 @@ module RightSupport::Rack
61
61
  return [status, header, body]
62
62
  rescue Exception => e
63
63
  log_exception(logger, e)
64
- raise e
64
+ raise
65
65
  end
66
66
 
67
67
  private
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
7
7
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
8
8
 
9
9
  s.name = 'right_support'
10
- s.version = '2.6.12'
11
- s.date = '2013-01-03'
10
+ s.version = '2.6.15'
11
+ s.date = '2013-01-23'
12
12
 
13
13
  s.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson', 'Lee Kirchhoff', 'Sergey Enin', 'Alexey Karpik', 'Scott Messier']
14
14
  s.email = 'support@rightscale.com'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_support
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 6
9
- - 12
10
- version: 2.6.12
9
+ - 15
10
+ version: 2.6.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Spataro
@@ -21,7 +21,7 @@ autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
23
 
24
- date: 2013-01-03 00:00:00 -08:00
24
+ date: 2013-01-23 00:00:00 -08:00
25
25
  default_executable:
26
26
  dependencies: []
27
27