right_agent 2.2.1-x86-mingw32 → 2.4.3-x86-mingw32
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/README.rdoc +2 -0
- data/lib/right_agent.rb +1 -0
- data/lib/right_agent/actor.rb +0 -28
- data/lib/right_agent/actors/agent_manager.rb +20 -18
- data/lib/right_agent/agent.rb +70 -87
- data/lib/right_agent/agent_config.rb +1 -1
- data/lib/right_agent/agent_tag_manager.rb +1 -1
- data/lib/right_agent/clients/api_client.rb +2 -1
- data/lib/right_agent/clients/auth_client.rb +2 -6
- data/lib/right_agent/clients/balanced_http_client.rb +22 -11
- data/lib/right_agent/clients/base_retry_client.rb +14 -22
- data/lib/right_agent/clients/non_blocking_client.rb +1 -0
- data/lib/right_agent/clients/right_http_client.rb +4 -8
- data/lib/right_agent/clients/router_client.rb +10 -16
- data/lib/right_agent/command/command_parser.rb +3 -3
- data/lib/right_agent/command/command_runner.rb +1 -1
- data/lib/right_agent/command/command_serializer.rb +0 -32
- data/lib/right_agent/connectivity_checker.rb +7 -11
- data/lib/right_agent/core_payload_types/dev_repository.rb +32 -0
- data/lib/right_agent/dispatcher.rb +8 -45
- data/lib/right_agent/enrollment_result.rb +2 -2
- data/lib/right_agent/error_tracker.rb +230 -0
- data/lib/right_agent/exceptions.rb +1 -1
- data/lib/right_agent/log.rb +8 -6
- data/lib/right_agent/packets.rb +5 -3
- data/lib/right_agent/pending_requests.rb +10 -4
- data/lib/right_agent/pid_file.rb +3 -3
- data/lib/right_agent/platform.rb +14 -14
- data/lib/right_agent/protocol_version_mixin.rb +6 -3
- data/lib/right_agent/scripts/agent_deployer.rb +13 -1
- data/lib/right_agent/sender.rb +16 -35
- data/lib/right_agent/serialize/secure_serializer.rb +6 -9
- data/lib/right_agent/serialize/serializer.rb +7 -3
- data/right_agent.gemspec +5 -5
- data/spec/agent_spec.rb +5 -5
- data/spec/clients/auth_client_spec.rb +1 -1
- data/spec/clients/balanced_http_client_spec.rb +20 -28
- data/spec/clients/base_retry_client_spec.rb +5 -6
- data/spec/clients/non_blocking_client_spec.rb +4 -0
- data/spec/clients/router_client_spec.rb +1 -4
- data/spec/dispatcher_spec.rb +6 -55
- data/spec/error_tracker_spec.rb +346 -0
- data/spec/log_spec.rb +4 -0
- data/spec/pending_requests_spec.rb +2 -2
- data/spec/sender_spec.rb +3 -3
- data/spec/serialize/serializer_spec.rb +14 -0
- data/spec/spec_helper.rb +4 -2
- metadata +13 -11
data/lib/right_agent/log.rb
CHANGED
@@ -200,10 +200,14 @@ module RightScale
|
|
200
200
|
description += " (#{exception}"
|
201
201
|
backtrace = :no_trace
|
202
202
|
end
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
203
|
+
if exception.respond_to?(:backtrace) && exception.backtrace
|
204
|
+
case backtrace
|
205
|
+
when :no_trace then description += ")"
|
206
|
+
when :caller then description += " in " + exception.backtrace[0] + ")"
|
207
|
+
when :trace then description += " in\n " + exception.backtrace.join("\n ") + ")"
|
208
|
+
end
|
209
|
+
else
|
210
|
+
description += ")"
|
207
211
|
end
|
208
212
|
end
|
209
213
|
description
|
@@ -410,8 +414,6 @@ module RightScale
|
|
410
414
|
@logger = logger
|
411
415
|
end
|
412
416
|
|
413
|
-
protected
|
414
|
-
|
415
417
|
# Initialize logger
|
416
418
|
#
|
417
419
|
# === Parameters
|
data/lib/right_agent/packets.rb
CHANGED
@@ -56,6 +56,10 @@ module RightScale
|
|
56
56
|
# Instance variables that are not serialized because they are only used locally
|
57
57
|
NOT_SERIALIZED = ["received_at"]
|
58
58
|
|
59
|
+
# Regexp for inserting packet size into msgpack encoded packet
|
60
|
+
# For ruby 1.9 size attribute moves from front to back of packet
|
61
|
+
PACKET_SIZE_REGEXP = RUBY_VERSION < "1.9.0" ? Regexp.new("size\xC0", nil, "n") : Regexp.new("size\xC0$", nil, "n")
|
62
|
+
|
59
63
|
# (Float) Time in seconds in Unix-epoch when message was received
|
60
64
|
attr_accessor :received_at
|
61
65
|
|
@@ -106,10 +110,8 @@ module RightScale
|
|
106
110
|
'size' => nil
|
107
111
|
}.to_msgpack(*a)
|
108
112
|
@size = msg.size
|
109
|
-
# For ruby 1.9 size attribute moves from front to back of packet
|
110
|
-
re = RUBY_VERSION < "1.9.0" ? /size\xC0/ : /size\xC0$/
|
111
113
|
# For msgpack 0.5.1 the to_msgpack result is a MessagePack::Packer so need to convert to string
|
112
|
-
msg = msg.to_s.sub!(
|
114
|
+
msg = msg.to_s.sub!(PACKET_SIZE_REGEXP) { |m| "size" + @size.to_msgpack }
|
113
115
|
msg
|
114
116
|
end
|
115
117
|
|
@@ -97,12 +97,15 @@ module RightScale
|
|
97
97
|
|
98
98
|
# Get age of youngest pending request
|
99
99
|
#
|
100
|
+
# === Parameters
|
101
|
+
# pending_requests(Hash):: Pending requests to be examined
|
102
|
+
#
|
100
103
|
# === Return
|
101
104
|
# age(Integer):: Age of youngest request
|
102
|
-
def youngest_age
|
105
|
+
def self.youngest_age(pending_requests)
|
103
106
|
now = Time.now
|
104
107
|
age = nil
|
105
|
-
|
108
|
+
pending_requests.each_value do |r|
|
106
109
|
seconds = (now - r.receive_time).to_i
|
107
110
|
age = seconds if age.nil? || seconds < age
|
108
111
|
end
|
@@ -111,12 +114,15 @@ module RightScale
|
|
111
114
|
|
112
115
|
# Get age of oldest pending request
|
113
116
|
#
|
117
|
+
# === Parameters
|
118
|
+
# pending_requests(Hash):: Pending requests to be examined
|
119
|
+
#
|
114
120
|
# === Return
|
115
121
|
# age(Integer):: Age of oldest request
|
116
|
-
def oldest_age
|
122
|
+
def self.oldest_age(pending_requests)
|
117
123
|
now = Time.now
|
118
124
|
age = nil
|
119
|
-
|
125
|
+
pending_requests.each_value do |r|
|
120
126
|
seconds = (now - r.receive_time).to_i
|
121
127
|
age = seconds if age.nil? || seconds > age
|
122
128
|
end
|
data/lib/right_agent/pid_file.rb
CHANGED
@@ -31,7 +31,7 @@ module RightScale
|
|
31
31
|
# the command protocol
|
32
32
|
class PidFile
|
33
33
|
|
34
|
-
class AlreadyRunning <
|
34
|
+
class AlreadyRunning < RuntimeError; end
|
35
35
|
|
36
36
|
attr_reader :identity, :pid_file, :cookie_file
|
37
37
|
|
@@ -72,8 +72,8 @@ module RightScale
|
|
72
72
|
FileUtils.mkdir_p(@pid_dir)
|
73
73
|
open(@pid_file,'w') { |f| f.write(Process.pid) }
|
74
74
|
File.chmod(0644, @pid_file)
|
75
|
-
rescue
|
76
|
-
|
75
|
+
rescue StandardError => e
|
76
|
+
ErrorTracker.log(self, "Failed to create PID file", e, nil, :caller)
|
77
77
|
raise
|
78
78
|
end
|
79
79
|
true
|
data/lib/right_agent/platform.rb
CHANGED
@@ -248,6 +248,20 @@ unless defined?(RightScale::Platform)
|
|
248
248
|
output_text
|
249
249
|
end
|
250
250
|
|
251
|
+
# Determines which cloud we're on by the cheap but simple expedient of
|
252
|
+
# reading the RightScale cloud file.
|
253
|
+
#
|
254
|
+
# @deprecated leverage the right_link cloud libraries for any cloud-
|
255
|
+
# specific behavior because the behavior of all possible clouds is
|
256
|
+
# beyond the scope of hard-coded case statements.
|
257
|
+
#
|
258
|
+
# @return [String] cloud type or nil
|
259
|
+
def resolve_cloud_type
|
260
|
+
cloud_file_path = ::File.join(self.filesystem.right_scale_static_state_dir, 'cloud')
|
261
|
+
@cloud_type = ::File.read(cloud_file_path) rescue nil
|
262
|
+
@cloud_type
|
263
|
+
end
|
264
|
+
|
251
265
|
# Base class for platform helpers.
|
252
266
|
class PlatformHelperBase
|
253
267
|
|
@@ -745,20 +759,6 @@ unless defined?(RightScale::Platform)
|
|
745
759
|
return res
|
746
760
|
end
|
747
761
|
|
748
|
-
# Determines which cloud we're on by the cheap but simple expedient of
|
749
|
-
# reading the RightScale cloud file.
|
750
|
-
#
|
751
|
-
# @deprecated leverage the right_link cloud libraries for any cloud-
|
752
|
-
# specific behavior because the behavior of all possible clouds is
|
753
|
-
# beyond the scope of hard-coded case statements.
|
754
|
-
#
|
755
|
-
# @return [String] cloud type or nil
|
756
|
-
def resolve_cloud_type
|
757
|
-
cloud_file_path = ::File.join(self.filesystem.right_scale_static_state_dir, 'cloud')
|
758
|
-
@cloud_type = ::File.read(cloud_file_path) rescue nil
|
759
|
-
@cloud_type
|
760
|
-
end
|
761
|
-
|
762
762
|
end # Platform
|
763
763
|
|
764
764
|
end # RightScale
|
@@ -34,9 +34,9 @@ module RightScale
|
|
34
34
|
# Packet::DEFAULT_VERSION, which is true of all with version >= 12)
|
35
35
|
def can_put_version_in_packet?(version); version && version != 0 end
|
36
36
|
|
37
|
-
# Test whether given version of agent uses /
|
38
|
-
# deprecated TagQuery packet
|
39
|
-
def
|
37
|
+
# Test whether given version of agent uses /router/query_tags or /mapper/query_tags
|
38
|
+
# rather than the deprecated TagQuery packet
|
39
|
+
def can_use_router_query_tags?(version); version && version >= 8 end
|
40
40
|
|
41
41
|
# Test whether given version of agent can handle a request that is being retried
|
42
42
|
# as indicated by a retries count in the Request packet
|
@@ -64,6 +64,9 @@ module RightScale
|
|
64
64
|
# Test whether given version of agent can handle HTTP communication mode
|
65
65
|
def can_handle_http?(version); version && version >= 23 end
|
66
66
|
|
67
|
+
# Test whether given version of agent can always handle a hash payload
|
68
|
+
def can_always_handle_hash_payload?(version); version && version >= 24 end
|
69
|
+
|
67
70
|
end # ProtocolVersionMixin
|
68
71
|
|
69
72
|
end # RightScale
|
@@ -45,6 +45,8 @@
|
|
45
45
|
# --grace-timeout SEC Set number of seconds before graceful termination times out
|
46
46
|
# --[no-]dup-check Set whether to check for and reject duplicate requests, .e.g., due to retries
|
47
47
|
# --fiber-pool-size, -f N Set size of fiber pool
|
48
|
+
# --airbrake-endpoint URL Set URL for Airbrake endpoint for reporting exceptions to Errbit
|
49
|
+
# --airbrake-api-key KEY Set Airbrake API key for use in reporting exceptions to Errbit
|
48
50
|
# --options, -o KEY=VAL Set options that act as final override for any persisted configuration settings
|
49
51
|
# --monit Generate monit configuration file
|
50
52
|
# --test Build test deployment using default test settings
|
@@ -205,6 +207,14 @@ module RightScale
|
|
205
207
|
options[:heartbeat] = sec.to_i
|
206
208
|
end
|
207
209
|
|
210
|
+
opts.on('--airbrake-endpoint URL') do |url|
|
211
|
+
options[:airbrake_endpoint] = url
|
212
|
+
end
|
213
|
+
|
214
|
+
opts.on('--airbrake-api-key KEY') do |key|
|
215
|
+
options[:airbrake_api_key] = key
|
216
|
+
end
|
217
|
+
|
208
218
|
opts.on('-o', '--options OPT') do |e|
|
209
219
|
fail("Invalid option definition #{e}' (use '=' to separate name and value)") unless e.include?('=')
|
210
220
|
key, val = e.split(/=/)
|
@@ -277,7 +287,7 @@ module RightScale
|
|
277
287
|
actors_dirs = AgentConfig.actors_dirs
|
278
288
|
actors.each do |a|
|
279
289
|
found = false
|
280
|
-
actors_dirs.each { |d| break if found = File.exist?(File.normalize_path(File.join(d, "#{a}.rb"))) }
|
290
|
+
actors_dirs.each { |d| break if (found = File.exist?(File.normalize_path(File.join(d, "#{a}.rb")))) }
|
281
291
|
fail("Cannot find source for actor #{a.inspect} in #{actors_dirs.inspect}") unless found
|
282
292
|
end
|
283
293
|
true
|
@@ -318,6 +328,8 @@ module RightScale
|
|
318
328
|
cfg[:http_proxy] = options[:http_proxy] if options[:http_proxy]
|
319
329
|
cfg[:http_no_proxy] = options[:http_no_proxy] if options[:http_no_proxy]
|
320
330
|
cfg[:fiber_pool_size] = options[:fiber_pool_size] if options[:fiber_pool_size]
|
331
|
+
cfg[:airbrake_endpoint] = options[:airbrake_endpoint] if options[:airbrake_endpoint]
|
332
|
+
cfg[:airbrake_api_key] = options[:airbrake_api_key] if options[:airbrake_api_key]
|
321
333
|
cfg
|
322
334
|
end
|
323
335
|
|
data/lib/right_agent/sender.rb
CHANGED
@@ -68,10 +68,6 @@ module RightScale
|
|
68
68
|
#
|
69
69
|
# === Parameters
|
70
70
|
# agent(Agent):: Agent using this sender; uses its identity, client, and following options:
|
71
|
-
# :exception_callback(Proc):: Callback with following parameters that is activated on exception events:
|
72
|
-
# exception(Exception):: Exception
|
73
|
-
# message(Packet):: Message being processed
|
74
|
-
# agent(Agent):: Reference to agent
|
75
71
|
# :offline_queueing(Boolean):: Whether to queue request if client currently disconnected,
|
76
72
|
# also requires agent invocation of initialize_offline_queue and start_offline_queue methods below,
|
77
73
|
# as well as enable_offline_mode and disable_offline_mode as client connection status changes
|
@@ -102,7 +98,7 @@ module RightScale
|
|
102
98
|
@connectivity_checker = if @mode == :amqp
|
103
99
|
# Only need connectivity checker for AMQP broker since RightHttpClient does its own checking
|
104
100
|
# via periodic session renewal
|
105
|
-
ConnectivityChecker.new(self, @options[:ping_interval] || 0, @ping_stats
|
101
|
+
ConnectivityChecker.new(self, @options[:ping_interval] || 0, @ping_stats)
|
106
102
|
end
|
107
103
|
@@instance = self
|
108
104
|
end
|
@@ -369,9 +365,9 @@ module RightScale
|
|
369
365
|
token = response.token
|
370
366
|
if (result = OperationResult.from_results(response))
|
371
367
|
if result.non_delivery?
|
372
|
-
@non_delivery_stats.update(result.content.nil? ? "nil" : result.content
|
368
|
+
@non_delivery_stats.update(result.content.nil? ? "nil" : result.content)
|
373
369
|
elsif result.error?
|
374
|
-
@result_error_stats.update(result.content.nil? ? "nil" : result.content
|
370
|
+
@result_error_stats.update(result.content.nil? ? "nil" : result.content)
|
375
371
|
end
|
376
372
|
@result_stats.update(result.status)
|
377
373
|
else
|
@@ -418,7 +414,7 @@ module RightScale
|
|
418
414
|
@offline_handler.terminate
|
419
415
|
@connectivity_checker.terminate if @connectivity_checker
|
420
416
|
pending = @pending_requests.kind(:send_request)
|
421
|
-
[pending.size,
|
417
|
+
[pending.size, PendingRequests.youngest_age(pending)]
|
422
418
|
else
|
423
419
|
[0, nil]
|
424
420
|
end
|
@@ -448,9 +444,6 @@ module RightScale
|
|
448
444
|
#
|
449
445
|
# === Return
|
450
446
|
# stats(Hash):: Current statistics:
|
451
|
-
# "exceptions"(Hash|nil):: Exceptions raised per category, or nil if none
|
452
|
-
# "total"(Integer):: Total exceptions for this category
|
453
|
-
# "recent"(Array):: Most recent as a hash of "count", "type", "message", "when", and "where"
|
454
447
|
# "non-deliveries"(Hash|nil):: Non-delivery activity stats with keys "total", "percent", "last",
|
455
448
|
# and 'rate' with percentage breakdown per reason, or nil if none
|
456
449
|
# "offlines"(Hash|nil):: Offline activity stats with keys "total", "last", and "duration",
|
@@ -463,7 +456,6 @@ module RightScale
|
|
463
456
|
# with percentage breakdown per request type, or nil if none
|
464
457
|
# "requests pending"(Hash|nil):: Number of requests waiting for response and age of oldest,
|
465
458
|
# or nil if none
|
466
|
-
# "response time"(Float):: Average number of seconds to respond to a request recently
|
467
459
|
# "result errors"(Hash|nil):: Error result activity stats with keys "total", "percent", "last",
|
468
460
|
# and 'rate' with percentage breakdown per error, or nil if none
|
469
461
|
# "results"(Hash|nil):: Results activity stats with keys "total", "percent", "last", and "rate"
|
@@ -482,18 +474,16 @@ module RightScale
|
|
482
474
|
pending["pushes"] = @pending_requests.kind(:send_push).size
|
483
475
|
requests = @pending_requests.kind(:send_request)
|
484
476
|
if (pending["requests"] = requests.size) > 0
|
485
|
-
pending["oldest age"] =
|
477
|
+
pending["oldest age"] = PendingRequests.oldest_age(requests)
|
486
478
|
end
|
487
479
|
end
|
488
480
|
stats = {
|
489
|
-
"exceptions" => @exception_stats.stats,
|
490
481
|
"non-deliveries" => @non_delivery_stats.all,
|
491
482
|
"offlines" => offlines,
|
492
483
|
"pings" => @ping_stats.all,
|
493
484
|
"request kinds" => @request_kind_stats.all,
|
494
485
|
"requests" => @request_stats.all,
|
495
486
|
"requests pending" => pending,
|
496
|
-
"response time" => @request_stats.avg_duration,
|
497
487
|
"result errors" => @result_error_stats.all,
|
498
488
|
"results" => @result_stats.all,
|
499
489
|
"retries" => @retry_stats.all,
|
@@ -520,7 +510,6 @@ module RightScale
|
|
520
510
|
@offline_stats = RightSupport::Stats::Activity.new(measure_rate = false)
|
521
511
|
@request_kind_stats = RightSupport::Stats::Activity.new(measure_rate = false)
|
522
512
|
@send_failure_stats = RightSupport::Stats::Activity.new
|
523
|
-
@exception_stats = RightSupport::Stats::Exceptions.new(@agent, @options[:exception_callback])
|
524
513
|
true
|
525
514
|
end
|
526
515
|
|
@@ -614,9 +603,8 @@ module RightScale
|
|
614
603
|
EM_S.next_tick do
|
615
604
|
begin
|
616
605
|
http_send_once(kind, target, packet, received_at, &callback)
|
617
|
-
rescue
|
618
|
-
|
619
|
-
@exception_stats.track("request", e)
|
606
|
+
rescue StandardError => e
|
607
|
+
ErrorTracker.log(self, "Failed sending or handling response for #{packet.trace} #{packet.type}", e)
|
620
608
|
end
|
621
609
|
end
|
622
610
|
else
|
@@ -668,8 +656,7 @@ module RightScale
|
|
668
656
|
result = error_result(e.inspect)
|
669
657
|
else
|
670
658
|
agent_type = AgentIdentity.parse(@identity).agent_type
|
671
|
-
|
672
|
-
@exception_stats.track("request", e)
|
659
|
+
ErrorTracker.log(self, "Failed to send #{packet.trace} #{packet.type}", e)
|
673
660
|
result = error_result("#{agent_type.capitalize} agent internal error")
|
674
661
|
end
|
675
662
|
end
|
@@ -739,21 +726,17 @@ module RightScale
|
|
739
726
|
# TemporarilyOffline:: If cannot send request because RightNet client currently disconnected
|
740
727
|
# and offline queueing is disabled
|
741
728
|
def amqp_send_once(packet, ids = nil)
|
742
|
-
name =
|
743
729
|
exchange = {:type => :fanout, :name => @request_queue, :options => {:durable => true, :no_declare => @secure}}
|
744
730
|
@agent.client.publish(exchange, packet, :persistent => packet.persistent, :mandatory => true,
|
745
731
|
:log_filter => [:tags, :target, :tries, :persistent], :brokers => ids)
|
746
732
|
rescue RightAMQP::HABrokerClient::NoConnectedBrokers => e
|
747
|
-
|
748
|
-
Log.error(msg, e)
|
733
|
+
ErrorTracker.log(self, error = "Failed to publish request #{packet.trace} #{packet.type}", e, packet)
|
749
734
|
@send_failure_stats.update("NoConnectedBrokers")
|
750
|
-
raise TemporarilyOffline.new(
|
751
|
-
rescue
|
752
|
-
|
753
|
-
Log.error(msg, e, :trace)
|
735
|
+
raise TemporarilyOffline.new(error + " (#{e.class}: #{e.message})")
|
736
|
+
rescue StandardError => e
|
737
|
+
ErrorTracker.log(self, error = "Failed to publish request #{packet.trace} #{packet.type}", e, packet)
|
754
738
|
@send_failure_stats.update(e.class.name)
|
755
|
-
|
756
|
-
raise SendFailure.new(msg + " (#{e.class}: #{e.message})")
|
739
|
+
raise SendFailure.new(error + " (#{e.class}: #{e.message})")
|
757
740
|
end
|
758
741
|
|
759
742
|
# Send request via AMQP with one or more retries if do not receive a response in time
|
@@ -796,20 +779,18 @@ module RightScale
|
|
796
779
|
else
|
797
780
|
Log.warning("RE-SEND TIMEOUT after #{elapsed.to_i} seconds for #{packet.trace} #{packet.type}")
|
798
781
|
result = OperationResult.non_delivery(OperationResult::RETRY_TIMEOUT)
|
799
|
-
@non_delivery_stats.update(result.content)
|
800
782
|
handle_response(Result.new(packet.token, @identity, result, @identity))
|
801
783
|
end
|
802
784
|
@connectivity_checker.check(check_broker_ids.first) if check_broker_ids.any? && count == 1
|
803
785
|
end
|
804
786
|
rescue TemporarilyOffline => e
|
805
|
-
|
787
|
+
ErrorTracker.log(self, "Failed retry for #{packet.trace} #{packet.type} because temporarily offline")
|
806
788
|
rescue SendFailure => e
|
807
|
-
|
789
|
+
ErrorTracker.log(self, "Failed retry for #{packet.trace} #{packet.type} because of send failure")
|
808
790
|
rescue Exception => e
|
809
791
|
# Not sending a response here because something more basic is broken in the retry
|
810
792
|
# mechanism and don't want an error response to preempt a delayed actual response
|
811
|
-
|
812
|
-
@exception_stats.track("retry", e, packet)
|
793
|
+
ErrorTracker.log(self, "Failed retry for #{packet.trace} #{packet.type} without responding", e, packet)
|
813
794
|
end
|
814
795
|
end
|
815
796
|
end
|
@@ -28,9 +28,9 @@ module RightScale
|
|
28
28
|
|
29
29
|
include ProtocolVersionMixin
|
30
30
|
|
31
|
-
class MissingPrivateKey <
|
32
|
-
class MissingCertificate <
|
33
|
-
class InvalidSignature <
|
31
|
+
class MissingPrivateKey < StandardError; end
|
32
|
+
class MissingCertificate < StandardError; end
|
33
|
+
class InvalidSignature < StandardError; end
|
34
34
|
|
35
35
|
# Create the one and only SecureSerializer
|
36
36
|
def self.init(serializer, identity, store, encrypt = true)
|
@@ -87,9 +87,6 @@ module RightScale
|
|
87
87
|
#
|
88
88
|
# === Return
|
89
89
|
# (String):: MessagePack serialized and optionally encrypted object
|
90
|
-
#
|
91
|
-
# === Raise
|
92
|
-
# Exception:: If certificate identity, certificate store, certificate, or private key missing
|
93
90
|
def dump(obj, encrypt = nil)
|
94
91
|
must_encrypt = encrypt || @encrypt
|
95
92
|
serialize_format = if obj.respond_to?(:send_version) && can_handle_msgpack_result?(obj.send_version)
|
@@ -105,7 +102,7 @@ module RightScale
|
|
105
102
|
msg = EncryptedDocument.new(msg, certs).encrypted_data(encode_format)
|
106
103
|
else
|
107
104
|
target = obj.target_for_encryption if obj.respond_to?(:target_for_encryption)
|
108
|
-
|
105
|
+
ErrorTracker.log(self, "No certs available for object #{obj.class} being sent to #{target.inspect}") if target
|
109
106
|
end
|
110
107
|
end
|
111
108
|
sig = Signature.new(msg, @cert, @key).data(encode_format)
|
@@ -124,8 +121,8 @@ module RightScale
|
|
124
121
|
# (Object):: Unserialized object
|
125
122
|
#
|
126
123
|
# === Raise
|
127
|
-
#
|
128
|
-
#
|
124
|
+
# MissingCertificate:: If could not find certificate for message signer or receiver
|
125
|
+
# MissingPrivateKey:: If could not find private key for message receiver
|
129
126
|
# InvalidSignature:: If message signature check failed for message
|
130
127
|
def load(msg, id = nil)
|
131
128
|
msg = @serializer.load(msg)
|
@@ -140,15 +140,19 @@ module RightScale
|
|
140
140
|
#
|
141
141
|
# === Raises
|
142
142
|
# SerializationError:: If none of the serializers can perform the requested action
|
143
|
+
# RightScale::Exceptions::ConnectivityFailure:: If cannot access external services
|
143
144
|
def cascade_serializers(action, packet, serializers, id = nil)
|
144
145
|
errors = []
|
145
146
|
serializers.map do |serializer|
|
146
147
|
obj = nil
|
147
148
|
begin
|
148
|
-
obj = serializer == SecureSerializer ? serializer.send(action, packet, id) :
|
149
|
-
rescue
|
149
|
+
obj = serializer == SecureSerializer ? serializer.send(action, packet, id) : serializer.send(action, packet)
|
150
|
+
rescue RightSupport::Net::NoResult, SocketError => e
|
151
|
+
raise Exceptions::ConnectivityFailure.new("Failed to #{action} with #{serializer.name} due to external " +
|
152
|
+
"service access failures (#{e.class.name}: #{e.message})", e)
|
153
|
+
rescue SecureSerializer::MissingCertificate, SecureSerializer::MissingPrivateKey, SecureSerializer::InvalidSignature => e
|
150
154
|
errors << Log.format("Failed to #{action} with #{serializer.name}", e)
|
151
|
-
rescue
|
155
|
+
rescue StandardError => e
|
152
156
|
errors << Log.format("Failed to #{action} with #{serializer.name}", e, :trace)
|
153
157
|
end
|
154
158
|
return obj if obj
|
data/right_agent.gemspec
CHANGED
@@ -25,8 +25,8 @@ require 'rbconfig'
|
|
25
25
|
|
26
26
|
Gem::Specification.new do |spec|
|
27
27
|
spec.name = 'right_agent'
|
28
|
-
spec.version = '2.
|
29
|
-
spec.date = '2014-
|
28
|
+
spec.version = '2.4.3'
|
29
|
+
spec.date = '2014-10-02'
|
30
30
|
spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro', 'Scott Messier']
|
31
31
|
spec.email = 'lee@rightscale.com'
|
32
32
|
spec.homepage = 'https://github.com/rightscale/right_agent'
|
@@ -39,9 +39,9 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.require_path = 'lib'
|
40
40
|
|
41
41
|
spec.add_dependency('right_support', ['>= 2.4.1', '< 3.0'])
|
42
|
-
spec.add_dependency('right_amqp', '~> 0.
|
43
|
-
spec.add_dependency('rest-client', '1.7.0.
|
44
|
-
spec.add_dependency('faye-websocket', '0.7.0')
|
42
|
+
spec.add_dependency('right_amqp', '~> 0.8')
|
43
|
+
spec.add_dependency('rest-client', '~> 1.7.0.3')
|
44
|
+
spec.add_dependency('faye-websocket', '~> 0.7.0')
|
45
45
|
spec.add_dependency('eventmachine', ['>= 0.12.10', '< 2.0'])
|
46
46
|
spec.add_dependency('net-ssh', '~> 2.0')
|
47
47
|
|