right_agent 2.4.2 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -205,6 +205,7 @@ module RightScale
205
205
  case error.to_s
206
206
  when "terminating", "reconnecting" then [200, nil]
207
207
  when "Errno::ETIMEDOUT" then [408, "Request timeout"]
208
+ when "Errno::ECONNREFUSED" then [503, "Connection refused"]
208
209
  else [500, (error && error.to_s) || "HTTP connection failure for #{verb.to_s.upcase}"]
209
210
  end
210
211
  end
@@ -36,7 +36,7 @@ module RightScale
36
36
  end
37
37
 
38
38
  # Internal application error
39
- class Application < StandardError; end
39
+ class Application < NestedException; end
40
40
 
41
41
  # Agent command IO error
42
42
  class IO < RuntimeError; end
@@ -200,10 +200,14 @@ module RightScale
200
200
  description += " (#{exception}"
201
201
  backtrace = :no_trace
202
202
  end
203
- case backtrace
204
- when :no_trace then description += ")"
205
- when :caller then description += " in " + exception.backtrace[0] + ")"
206
- when :trace then description += " in\n " + exception.backtrace.join("\n ") + ")"
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
@@ -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)
@@ -124,8 +121,8 @@ module RightScale
124
121
  # (Object):: Unserialized object
125
122
  #
126
123
  # === Raise
127
- # Exception:: If certificate store, certificate, or private key missing
128
- # MissingCertificate:: If could not find certificate for message signer
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) : serializer.send(action, packet)
149
- rescue SecureSerializer::MissingCertificate, SecureSerializer::InvalidSignature => e
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 Exception => e
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.4.2'
29
- spec.date = '2014-08-26'
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,7 +39,7 @@ 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.7')
42
+ spec.add_dependency('right_amqp', '~> 0.8')
43
43
  spec.add_dependency('rest-client', '~> 1.7.0.3')
44
44
  spec.add_dependency('faye-websocket', '~> 0.7.0')
45
45
  spec.add_dependency('eventmachine', ['>= 0.12.10', '< 2.0'])
@@ -404,6 +404,10 @@ describe RightScale::NonBlockingClient do
404
404
  @client.send(:handle_error, :get, Errno::ETIMEDOUT).should == [408, "Request timeout"]
405
405
  end
406
406
 
407
+ it "converts Errno::ECONNREFUSED to 503 ServiceUnavailable" do
408
+ @client.send(:handle_error, :get, Errno::ECONNREFUSED).should == [503, "Connection refused"]
409
+ end
410
+
407
411
  it "converts error to 500 InternalServerError by default" do
408
412
  @client.send(:handle_error, :get, "failed").should == [500, "failed"]
409
413
  end
data/spec/log_spec.rb CHANGED
@@ -187,6 +187,10 @@ describe RightScale::Log do
187
187
  log_count("Test error \\\(NoMethodError: undefined method \\\`\\\+\' for nil:NilClass in$").should == 1
188
188
  end
189
189
 
190
+ it 'should not attempt to use backtrace if exception has none' do
191
+ RightScale::Log.error("Test error", RuntimeError.new("failed"), :trace)
192
+ log_count("Test error \\\(RuntimeError: failed\\\)$").should == 1
193
+ end
190
194
  end
191
195
 
192
196
  end
@@ -77,6 +77,12 @@ describe RightScale::Serializer do
77
77
  lambda { serializer.dump("hello") }.should raise_error(RightScale::Serializer::SerializationError)
78
78
  end
79
79
 
80
+ it "should raise ConnectivityFailure if packet could not be serialized for connectivity reasons" do
81
+ flexmock(RightScale::SecureSerializer).should_receive(:dump).with("hello", nil).and_raise(SocketError).once
82
+ serializer = RightScale::Serializer.new(:secure)
83
+ lambda { serializer.dump("hello") }.should raise_error(RightScale::Exceptions::ConnectivityFailure)
84
+ end
85
+
80
86
  it "should return serialized packet" do
81
87
  serialized_packet = flexmock("Packet")
82
88
  flexmock(MessagePack).should_receive(:dump).with("hello").and_return(serialized_packet).once
@@ -185,6 +191,14 @@ describe RightScale::Serializer do
185
191
  lambda { serializer.load("olleh") }.should raise_error(RightScale::Serializer::SerializationError)
186
192
  end
187
193
 
194
+ it "should raise ConnectivityFailure if packet could not be unserialized for connectivity reasons" do
195
+ serialized = "securely serialized"
196
+ flexmock(RightScale::SecureSerializer).should_receive(:load).with(serialized, "id").
197
+ and_raise(RightSupport::Net::NoResult.new("failed")).once
198
+ serializer = RightScale::Serializer.new(:secure)
199
+ lambda { serializer.load(serialized, "id") }.should raise_error(RightScale::Exceptions::ConnectivityFailure)
200
+ end
201
+
188
202
  it "should return unserialized packet" do
189
203
  unserialized_packet = flexmock("Packet")
190
204
  flexmock(MessagePack).should_receive(:load).with("olleh").and_return(unserialized_packet).once
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Lee Kirchhoff
@@ -11,164 +12,194 @@ authors:
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2014-08-26 00:00:00.000000000 Z
15
+ date: 2014-10-02 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: right_support
18
19
  requirement: !ruby/object:Gem::Requirement
20
+ none: false
19
21
  requirements:
20
- - - ">="
22
+ - - ! '>='
21
23
  - !ruby/object:Gem::Version
22
24
  version: 2.4.1
23
- - - "<"
25
+ - - <
24
26
  - !ruby/object:Gem::Version
25
27
  version: '3.0'
26
28
  type: :runtime
27
29
  prerelease: false
28
30
  version_requirements: !ruby/object:Gem::Requirement
31
+ none: false
29
32
  requirements:
30
- - - ">="
33
+ - - ! '>='
31
34
  - !ruby/object:Gem::Version
32
35
  version: 2.4.1
33
- - - "<"
36
+ - - <
34
37
  - !ruby/object:Gem::Version
35
38
  version: '3.0'
36
39
  - !ruby/object:Gem::Dependency
37
40
  name: right_amqp
38
41
  requirement: !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
- - - "~>"
44
+ - - ~>
41
45
  - !ruby/object:Gem::Version
42
- version: '0.7'
46
+ version: '0.8'
43
47
  type: :runtime
44
48
  prerelease: false
45
49
  version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
46
51
  requirements:
47
- - - "~>"
52
+ - - ~>
48
53
  - !ruby/object:Gem::Version
49
- version: '0.7'
54
+ version: '0.8'
50
55
  - !ruby/object:Gem::Dependency
51
56
  name: rest-client
52
57
  requirement: !ruby/object:Gem::Requirement
58
+ none: false
53
59
  requirements:
54
- - - "~>"
60
+ - - ~>
55
61
  - !ruby/object:Gem::Version
56
62
  version: 1.7.0.3
57
63
  type: :runtime
58
64
  prerelease: false
59
65
  version_requirements: !ruby/object:Gem::Requirement
66
+ none: false
60
67
  requirements:
61
- - - "~>"
68
+ - - ~>
62
69
  - !ruby/object:Gem::Version
63
70
  version: 1.7.0.3
64
71
  - !ruby/object:Gem::Dependency
65
72
  name: faye-websocket
66
73
  requirement: !ruby/object:Gem::Requirement
74
+ none: false
67
75
  requirements:
68
- - - "~>"
76
+ - - ~>
69
77
  - !ruby/object:Gem::Version
70
78
  version: 0.7.0
71
79
  type: :runtime
72
80
  prerelease: false
73
81
  version_requirements: !ruby/object:Gem::Requirement
82
+ none: false
74
83
  requirements:
75
- - - "~>"
84
+ - - ~>
76
85
  - !ruby/object:Gem::Version
77
86
  version: 0.7.0
78
87
  - !ruby/object:Gem::Dependency
79
88
  name: eventmachine
80
89
  requirement: !ruby/object:Gem::Requirement
90
+ none: false
81
91
  requirements:
82
- - - ">="
92
+ - - ! '>='
83
93
  - !ruby/object:Gem::Version
84
94
  version: 0.12.10
85
- - - "<"
95
+ - - <
86
96
  - !ruby/object:Gem::Version
87
97
  version: '2.0'
88
98
  type: :runtime
89
99
  prerelease: false
90
100
  version_requirements: !ruby/object:Gem::Requirement
101
+ none: false
91
102
  requirements:
92
- - - ">="
103
+ - - ! '>='
93
104
  - !ruby/object:Gem::Version
94
105
  version: 0.12.10
95
- - - "<"
106
+ - - <
96
107
  - !ruby/object:Gem::Version
97
108
  version: '2.0'
98
109
  - !ruby/object:Gem::Dependency
99
110
  name: net-ssh
100
111
  requirement: !ruby/object:Gem::Requirement
112
+ none: false
101
113
  requirements:
102
- - - "~>"
114
+ - - ~>
103
115
  - !ruby/object:Gem::Version
104
116
  version: '2.0'
105
117
  type: :runtime
106
118
  prerelease: false
107
119
  version_requirements: !ruby/object:Gem::Requirement
120
+ none: false
108
121
  requirements:
109
- - - "~>"
122
+ - - ~>
110
123
  - !ruby/object:Gem::Version
111
124
  version: '2.0'
112
125
  - !ruby/object:Gem::Dependency
113
126
  name: ffi
114
127
  requirement: !ruby/object:Gem::Requirement
128
+ none: false
115
129
  requirements:
116
- - - ">="
130
+ - - ! '>='
117
131
  - !ruby/object:Gem::Version
118
132
  version: '0'
119
133
  type: :runtime
120
134
  prerelease: false
121
135
  version_requirements: !ruby/object:Gem::Requirement
136
+ none: false
122
137
  requirements:
123
- - - ">="
138
+ - - ! '>='
124
139
  - !ruby/object:Gem::Version
125
140
  version: '0'
126
141
  - !ruby/object:Gem::Dependency
127
142
  name: msgpack
128
143
  requirement: !ruby/object:Gem::Requirement
144
+ none: false
129
145
  requirements:
130
- - - ">="
146
+ - - ! '>='
131
147
  - !ruby/object:Gem::Version
132
148
  version: 0.4.4
133
- - - "<"
149
+ - - <
134
150
  - !ruby/object:Gem::Version
135
151
  version: '0.6'
136
152
  type: :runtime
137
153
  prerelease: false
138
154
  version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
139
156
  requirements:
140
- - - ">="
157
+ - - ! '>='
141
158
  - !ruby/object:Gem::Version
142
159
  version: 0.4.4
143
- - - "<"
160
+ - - <
144
161
  - !ruby/object:Gem::Version
145
162
  version: '0.6'
146
163
  - !ruby/object:Gem::Dependency
147
164
  name: json
148
165
  requirement: !ruby/object:Gem::Requirement
166
+ none: false
149
167
  requirements:
150
- - - "~>"
168
+ - - ~>
151
169
  - !ruby/object:Gem::Version
152
170
  version: '1.4'
153
171
  type: :runtime
154
172
  prerelease: false
155
173
  version_requirements: !ruby/object:Gem::Requirement
174
+ none: false
156
175
  requirements:
157
- - - "~>"
176
+ - - ~>
158
177
  - !ruby/object:Gem::Version
159
178
  version: '1.4'
160
- description: |
161
- RightAgent provides a foundation for running an agent on a server to interface
179
+ description: ! 'RightAgent provides a foundation for running an agent on a server
180
+ to interface
181
+
162
182
  in a secure fashion with other agents in the RightScale system using RightNet,
183
+
163
184
  which operates in either HTTP or AMQP mode. When using HTTP, RightAgent
185
+
164
186
  makes requests to RightApi servers and receives requests using long-polling or
187
+
165
188
  WebSockets via the RightNet router. To respond to requests it posts to the
189
+
166
190
  HTTP router. When using AMQP, RightAgent uses RabbitMQ as the message bus and
191
+
167
192
  the RightNet router as the routing node to make requests; to receives requests
193
+
168
194
  routed to it by the RightNet router, it establishes a queue on startup. The
195
+
169
196
  packets are structured to invoke services in the agent represented by actors
197
+
170
198
  and methods. The RightAgent may respond to these requests with a result packet
199
+
171
200
  that the router then routes to the originator.
201
+
202
+ '
172
203
  email: lee@rightscale.com
173
204
  executables: []
174
205
  extensions: []
@@ -361,29 +392,33 @@ files:
361
392
  - spec/tracer_spec.rb
362
393
  homepage: https://github.com/rightscale/right_agent
363
394
  licenses: []
364
- metadata: {}
365
395
  post_install_message:
366
396
  rdoc_options:
367
- - "--main"
397
+ - --main
368
398
  - README.rdoc
369
- - "--title"
399
+ - --title
370
400
  - RightAgent
371
401
  require_paths:
372
402
  - lib
373
403
  required_ruby_version: !ruby/object:Gem::Requirement
404
+ none: false
374
405
  requirements:
375
- - - ">="
406
+ - - ! '>='
376
407
  - !ruby/object:Gem::Version
377
408
  version: 1.8.7
378
409
  required_rubygems_version: !ruby/object:Gem::Requirement
410
+ none: false
379
411
  requirements:
380
- - - ">="
412
+ - - ! '>='
381
413
  - !ruby/object:Gem::Version
382
414
  version: '0'
415
+ segments:
416
+ - 0
417
+ hash: -3291070338952462239
383
418
  requirements: []
384
419
  rubyforge_project:
385
- rubygems_version: 2.2.2
420
+ rubygems_version: 1.8.26
386
421
  signing_key:
387
- specification_version: 4
422
+ specification_version: 3
388
423
  summary: Agent for interfacing server with RightScale system
389
424
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 2f847073e46487c064b8b6f889f911cce5e4f108
4
- data.tar.gz: 3d3e8c151fd4175d18925826183e06fa53492d1b
5
- SHA512:
6
- metadata.gz: 9422e92a47df194278674c186abb7f0b28d8235b901ae01a5c1313f4e3955a66515717a6b2ef47acd90a8e838f4c6734399978b5d50a8ed24096bfcae0e8e7b3
7
- data.tar.gz: ad341db3b0ff0a704ccee785966cefedc0c134ec7c71a259e6973969a968b05a6358b3685b90c4d76dd030b09ee0cd444f6d706aab7a00909b8ee864e127015f