right_support 2.6.12 → 2.6.15
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/lib/right_support/ci/java_spec_formatter.rb +9 -1
- data/lib/right_support/net/dns.rb +1 -1
- data/lib/right_support/net/lb/health_check.rb +1 -1
- data/lib/right_support/net/lb/sticky.rb +1 -1
- data/lib/right_support/net/request_balancer.rb +47 -26
- data/lib/right_support/net/ssl.rb +1 -1
- data/lib/right_support/rack/request_logger.rb +1 -1
- data/right_support.gemspec +2 -2
- metadata +4 -4
@@ -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
|
98
|
+
exception.nil? ? "" : "#{exception.message}\n#{format_backtrace(exception.backtrace)}"
|
91
99
|
end
|
92
100
|
|
93
101
|
def classname_for(example)
|
@@ -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
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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}")
|
data/right_support.gemspec
CHANGED
@@ -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.
|
11
|
-
s.date = '2013-01-
|
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:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 2.6.
|
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-
|
24
|
+
date: 2013-01-23 00:00:00 -08:00
|
25
25
|
default_executable:
|
26
26
|
dependencies: []
|
27
27
|
|