right_agent 0.17.0 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,8 +31,9 @@ module RightScale
31
31
  #
32
32
  # === Parameters
33
33
  # identity(String):: Serialized agent identity
34
- def initialize(identity)
35
- @pid = Process.pid
34
+ # pid(Integer):: Process ID of agent, defaults to ID if current process
35
+ def initialize(identity, pid = nil)
36
+ @pid = pid || Process.pid
36
37
  @history = File.join(AgentConfig.pid_dir, identity + ".history")
37
38
  end
38
39
 
@@ -99,29 +99,36 @@ module RightScale
99
99
  e
100
100
  end
101
101
 
102
- # Instantiate from request results
103
- # Ignore all but first result if results is a hash
102
+ # Instantiate from request result
103
+ # Ignore all but first result if result is a hash
104
104
  #
105
105
  # === Parameters
106
- # results(Result|Hash|OperationResult|nil):: Result or the Result "results" field
106
+ # result(Result|Hash|OperationResult|nil):: Result or the Result "results" field
107
107
  #
108
108
  # === Return
109
109
  # (RightScale::OperationResult):: Converted operation result
110
- def self.from_results(results)
111
- r = results.kind_of?(Result) ? results.results : results
110
+ def self.from_results(result)
111
+ r = result.is_a?(Result) ? result.results : result
112
112
  if r && r.respond_to?(:status_code) && r.respond_to?(:content)
113
113
  new(r.status_code, r.content)
114
- elsif r && r.kind_of?(Hash) && r.values.size > 0
114
+ elsif r && r.is_a?(Hash) && r.values.size > 0
115
115
  r = r.values[0]
116
116
  if r.respond_to?(:status_code) && r.respond_to?(:content)
117
117
  new(r.status_code, r.content)
118
118
  else
119
119
  error("Invalid operation result content: #{r.inspect}")
120
120
  end
121
+ elsif r && r.is_a?(String)
122
+ # This is not a supported return value but older RightLink versions can incorrectly
123
+ # return a String rather than an OperationResult#error in situations where the actor
124
+ # raises an exception when processing a request
125
+ error(r)
121
126
  elsif r.nil?
122
127
  error("No results")
128
+ elsif result.is_a?(Result)
129
+ error("Invalid results in Result from #{result.from}: #{result.results.inspect}")
123
130
  else
124
- error("Invalid operation result type: #{results.inspect}")
131
+ error("Invalid operation result type: #{result.inspect}")
125
132
  end
126
133
  end
127
134
 
@@ -919,7 +919,7 @@ module RightScale
919
919
 
920
920
  if handler = @pending_requests[token]
921
921
  if result && result.non_delivery? && handler.kind == :send_retryable_request
922
- if [OperationResult::TARGET_NOT_CONNECTED, OperationResult::TTL_EXPIRATION].include?(result.content)
922
+ if result.content == OperationResult::TARGET_NOT_CONNECTED
923
923
  # Log and temporarily ignore so that timeout retry mechanism continues, but save reason for use below if timeout
924
924
  # Leave purging of associated request until final response, i.e., success response or retry timeout
925
925
  if parent = handler.retry_parent
@@ -26,7 +26,18 @@ module RightScale
26
26
  # MessagePack and JSON serializable types that are sent to and from agents
27
27
  module Serializable
28
28
 
29
+ @check_active_support = true
30
+
29
31
  def self.included(base)
32
+ if @check_active_support
33
+ if require_succeeds?("active_support") && (v = Gem.loaded_specs['activesupport'].version.to_s) != "2.3.5"
34
+ raise Exception.new("Some versions of the activesupport gem modify json in ways that are incompatible with this " +
35
+ "RightScale::Serializable module. Version #{v} used here is not allowed, use 2.3.5 instead.")
36
+ else
37
+ @check_active_support = false
38
+ end
39
+ end
40
+
30
41
  base.extend ClassMethods
31
42
  base.send(:include, InstanceMethods)
32
43
  end
data/right_agent.gemspec CHANGED
@@ -24,8 +24,8 @@ require 'rubygems'
24
24
 
25
25
  Gem::Specification.new do |spec|
26
26
  spec.name = 'right_agent'
27
- spec.version = '0.17.0'
28
- spec.date = '2013-08-04'
27
+ spec.version = '0.17.2'
28
+ spec.date = '2013-10-28'
29
29
  spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro']
30
30
  spec.email = 'lee@rightscale.com'
31
31
  spec.homepage = 'https://github.com/rightscale/right_agent'
@@ -57,13 +57,29 @@ describe RightScale::OperationResult do
57
57
  result.content.should == "Error"
58
58
  end
59
59
 
60
- it "should return error OperationResult if results is nil" do
60
+ it "should convert unexpected string result into an error result" do
61
61
  result = RightScale::OperationResult.from_results(nil)
62
62
  result.kind_of?(RightScale::OperationResult).should be_true
63
63
  result.status_code.should == RightScale::OperationResult::ERROR
64
64
  result.content.should == "No results"
65
65
  end
66
66
 
67
+ it "should return error OperationResult if results is nil" do
68
+ string_result = RightScale::Result.new("token", "to", "Unexpected exception", "from")
69
+ result = RightScale::OperationResult.from_results(string_result)
70
+ result.kind_of?(RightScale::OperationResult).should be_true
71
+ result.status_code.should == RightScale::OperationResult::ERROR
72
+ result.content.should == "Unexpected exception"
73
+ end
74
+
75
+ it "should return error OperationResult including Result results if the results value is not recognized" do
76
+ array_result = RightScale::Result.new("token", "to", ["some data"], "from")
77
+ result = RightScale::OperationResult.from_results(array_result)
78
+ result.kind_of?(RightScale::OperationResult).should be_true
79
+ result.status_code.should == RightScale::OperationResult::ERROR
80
+ result.content.should == 'Invalid results in Result from from: ["some data"]'
81
+ end
82
+
67
83
  it "should return error OperationResult if the results value is not recognized" do
68
84
  result = RightScale::OperationResult.from_results(0)
69
85
  result.kind_of?(RightScale::OperationResult).should be_true
data/spec/sender_spec.rb CHANGED
@@ -815,7 +815,7 @@ describe RightScale::Sender do
815
815
  end
816
816
  @instance.pending_requests.empty?.should be_false
817
817
  token = @instance.pending_requests.keys.last
818
- non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::TTL_EXPIRATION)
818
+ non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::TARGET_NOT_CONNECTED)
819
819
  @instance.handle_response(RightScale::Result.new(token, 'iZac', non_delivery, "from"))
820
820
  EM.add_timer(1) do
821
821
  EM.stop
@@ -990,15 +990,12 @@ describe RightScale::Sender do
990
990
  @instance.handle_response(response)
991
991
  end
992
992
 
993
- it "should not deliver TARGET_NOT_CONNECTED and TTL_EXPIRATION responses for send_retryable_request" do
993
+ it "should not deliver TARGET_NOT_CONNECTED response for send_retryable_request" do
994
994
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
995
995
  flexmock(@instance).should_receive(:deliver).never
996
996
  non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::TARGET_NOT_CONNECTED)
997
997
  response = RightScale::Result.new('token1', 'to', non_delivery, 'target1')
998
998
  @instance.handle_response(response)
999
- non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::TTL_EXPIRATION)
1000
- response = RightScale::Result.new('token1', 'to', non_delivery, 'target1')
1001
- @instance.handle_response(response)
1002
999
  end
1003
1000
 
1004
1001
  it "should record non-delivery regardless of whether there is a response handler" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-08-04 00:00:00.000000000Z
14
+ date: 2013-10-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: right_support
18
- requirement: &2168887200 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -26,10 +26,18 @@ dependencies:
26
26
  version: '3.0'
27
27
  type: :runtime
28
28
  prerelease: false
29
- version_requirements: *2168887200
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: 2.4.1
35
+ - - <
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
30
38
  - !ruby/object:Gem::Dependency
31
39
  name: right_amqp
32
- requirement: &2168885180 !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
33
41
  none: false
34
42
  requirements:
35
43
  - - ~>
@@ -37,10 +45,15 @@ dependencies:
37
45
  version: '0.7'
38
46
  type: :runtime
39
47
  prerelease: false
40
- version_requirements: *2168885180
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.7'
41
54
  - !ruby/object:Gem::Dependency
42
55
  name: json
43
- requirement: &2168883820 !ruby/object:Gem::Requirement
56
+ requirement: !ruby/object:Gem::Requirement
44
57
  none: false
45
58
  requirements:
46
59
  - - ! '>='
@@ -51,10 +64,18 @@ dependencies:
51
64
  version: 1.7.6
52
65
  type: :runtime
53
66
  prerelease: false
54
- version_requirements: *2168883820
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '1.4'
73
+ - - <=
74
+ - !ruby/object:Gem::Version
75
+ version: 1.7.6
55
76
  - !ruby/object:Gem::Dependency
56
77
  name: eventmachine
57
- requirement: &2168882040 !ruby/object:Gem::Requirement
78
+ requirement: !ruby/object:Gem::Requirement
58
79
  none: false
59
80
  requirements:
60
81
  - - ! '>='
@@ -65,10 +86,18 @@ dependencies:
65
86
  version: '2.0'
66
87
  type: :runtime
67
88
  prerelease: false
68
- version_requirements: *2168882040
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: 0.12.10
95
+ - - <
96
+ - !ruby/object:Gem::Version
97
+ version: '2.0'
69
98
  - !ruby/object:Gem::Dependency
70
99
  name: msgpack
71
- requirement: &2168880380 !ruby/object:Gem::Requirement
100
+ requirement: !ruby/object:Gem::Requirement
72
101
  none: false
73
102
  requirements:
74
103
  - - ! '>='
@@ -79,10 +108,18 @@ dependencies:
79
108
  version: '0.6'
80
109
  type: :runtime
81
110
  prerelease: false
82
- version_requirements: *2168880380
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: 0.4.4
117
+ - - <
118
+ - !ruby/object:Gem::Version
119
+ version: '0.6'
83
120
  - !ruby/object:Gem::Dependency
84
121
  name: net-ssh
85
- requirement: &2168878400 !ruby/object:Gem::Requirement
122
+ requirement: !ruby/object:Gem::Requirement
86
123
  none: false
87
124
  requirements:
88
125
  - - ~>
@@ -90,7 +127,12 @@ dependencies:
90
127
  version: '2.0'
91
128
  type: :runtime
92
129
  prerelease: false
93
- version_requirements: *2168878400
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ version: '2.0'
94
136
  description: ! 'RightAgent provides a foundation for running an agent on a server
95
137
  to interface
96
138
 
@@ -289,10 +331,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
331
  version: '0'
290
332
  segments:
291
333
  - 0
292
- hash: 4577991098158607352
334
+ hash: 435154341923902142
293
335
  requirements: []
294
336
  rubyforge_project:
295
- rubygems_version: 1.8.10
337
+ rubygems_version: 1.8.26
296
338
  signing_key:
297
339
  specification_version: 3
298
340
  summary: Agent for interfacing server with RightScale system