right_agent 0.10.12 → 0.10.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/right_agent/sender.rb +7 -1
- data/right_agent.gemspec +2 -2
- data/spec/sender_spec.rb +22 -7
- metadata +33 -80
data/lib/right_agent/sender.rb
CHANGED
@@ -1130,7 +1130,13 @@ module RightScale
|
|
1130
1130
|
def publish_with_timeout_retry(request, parent, count = 0, multiplier = 1, elapsed = 0, broker_ids = nil)
|
1131
1131
|
published_broker_ids = publish(request, broker_ids)
|
1132
1132
|
|
1133
|
-
if
|
1133
|
+
if published_broker_ids.empty?
|
1134
|
+
# Could not publish request to any brokers, so respond with non-delivery
|
1135
|
+
# to allow requester, e.g., IdempotentRequest, to retry
|
1136
|
+
result = OperationResult.non_delivery("request send failed")
|
1137
|
+
@non_delivery_stats.update(result.content)
|
1138
|
+
handle_response(Result.new(request.token, request.reply_to, result, @identity))
|
1139
|
+
elsif @retry_interval && @retry_timeout && parent
|
1134
1140
|
interval = [(@retry_interval * multiplier) + (@request_stats.avg_duration || 0), @retry_timeout - elapsed].min
|
1135
1141
|
EM.add_timer(interval) do
|
1136
1142
|
begin
|
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.10.
|
28
|
-
spec.date = '
|
27
|
+
spec.version = '0.10.13'
|
28
|
+
spec.date = '2013-02-07'
|
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'
|
data/spec/sender_spec.rb
CHANGED
@@ -381,6 +381,7 @@ describe RightScale::Sender do
|
|
381
381
|
@timer = flexmock("timer")
|
382
382
|
flexmock(EM::Timer).should_receive(:new).and_return(@timer).by_default
|
383
383
|
flexmock(EM).should_receive(:next_tick).and_yield.by_default
|
384
|
+
flexmock(EM).should_receive(:defer).and_yield.by_default
|
384
385
|
@broker_id = "broker"
|
385
386
|
@broker_ids = [@broker_id]
|
386
387
|
@broker = flexmock("Broker", :subscribe => true, :publish => @broker_ids, :connected? => true,
|
@@ -414,7 +415,7 @@ describe RightScale::Sender do
|
|
414
415
|
it "should create a Request object" do
|
415
416
|
@broker.should_receive(:publish).with(hsh(:name => "request"), on do |request|
|
416
417
|
request.class.should == RightScale::Request
|
417
|
-
end, hsh(:persistent => false, :mandatory => true)).once
|
418
|
+
end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
|
418
419
|
@instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
|
419
420
|
end
|
420
421
|
|
@@ -432,7 +433,7 @@ describe RightScale::Sender do
|
|
432
433
|
request.from.should == 'agent'
|
433
434
|
request.target.should be_nil
|
434
435
|
request.expires_at.should == 1000100
|
435
|
-
end, hsh(:persistent => false, :mandatory => true)).once
|
436
|
+
end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
|
436
437
|
@instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
|
437
438
|
end
|
438
439
|
|
@@ -444,14 +445,14 @@ describe RightScale::Sender do
|
|
444
445
|
flexmock(Time).should_receive(:now).and_return(Time.at(1000000))
|
445
446
|
@broker.should_receive(:publish).with(hsh(:name => "request"), on do |request|
|
446
447
|
request.expires_at.should == 0
|
447
|
-
end, hsh(:persistent => false, :mandatory => true)).once
|
448
|
+
end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
|
448
449
|
@instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
|
449
450
|
end
|
450
451
|
|
451
452
|
it "should set the correct target if specified" do
|
452
453
|
@broker.should_receive(:publish).with(hsh(:name => "request"), on do |request|
|
453
454
|
request.target.should == 'my-target'
|
454
|
-
end, hsh(:persistent => false, :mandatory => true)).once
|
455
|
+
end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
|
455
456
|
@instance.send_retryable_request('/welcome/aboard', 'iZac', 'my-target') {|response|}
|
456
457
|
end
|
457
458
|
|
@@ -460,7 +461,7 @@ describe RightScale::Sender do
|
|
460
461
|
request.tags.should == ['tag']
|
461
462
|
request.selector.should == :any
|
462
463
|
request.scope.should == {:account => 123}
|
463
|
-
end, hsh(:persistent => false, :mandatory => true)).once
|
464
|
+
end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
|
464
465
|
@instance.send_retryable_request('/welcome/aboard', 'iZac', :tags => ['tag'], :scope => {:account => 123})
|
465
466
|
end
|
466
467
|
|
@@ -511,7 +512,7 @@ describe RightScale::Sender do
|
|
511
512
|
@agent.should_receive(:options).and_return({:retry_timeout => nil})
|
512
513
|
RightScale::Sender.new(@agent)
|
513
514
|
@instance = RightScale::Sender.instance
|
514
|
-
@broker.should_receive(:publish).once
|
515
|
+
@broker.should_receive(:publish).and_return(["rs-broker-host-123"]).once
|
515
516
|
@instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
|
516
517
|
end
|
517
518
|
|
@@ -520,7 +521,7 @@ describe RightScale::Sender do
|
|
520
521
|
@agent.should_receive(:options).and_return({:retry_interval => nil})
|
521
522
|
RightScale::Sender.new(@agent)
|
522
523
|
@instance = RightScale::Sender.instance
|
523
|
-
@broker.should_receive(:publish).once
|
524
|
+
@broker.should_receive(:publish).and_return(["rs-broker-host-123"]).once
|
524
525
|
@instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
|
525
526
|
end
|
526
527
|
|
@@ -533,6 +534,20 @@ describe RightScale::Sender do
|
|
533
534
|
@instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
|
534
535
|
end
|
535
536
|
|
537
|
+
it "should respond with non-delivery if publish failed" do
|
538
|
+
flexmock(EM).should_receive(:add_timer).never
|
539
|
+
@agent.should_receive(:options).and_return({:retry_timeout => 60, :retry_interval => 60})
|
540
|
+
RightScale::Sender.new(@agent)
|
541
|
+
@instance = RightScale::Sender.instance
|
542
|
+
@log.should_receive(:error).with(/Failed to publish request/, RightAMQP::HABrokerClient::NoConnectedBrokers).once
|
543
|
+
@broker.should_receive(:publish).and_raise(RightAMQP::HABrokerClient::NoConnectedBrokers).once
|
544
|
+
@instance.send_retryable_request('/welcome/aboard', 'iZac') do |response|
|
545
|
+
result = RightScale::OperationResult.from_results(response)
|
546
|
+
result.non_delivery?.should be_true
|
547
|
+
result.content.should == "request send failed"
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
536
551
|
it "should setup for retry if retry_timeout and retry_interval not nil and publish successful" do
|
537
552
|
flexmock(EM).should_receive(:add_timer).with(60, any).once
|
538
553
|
@agent.should_receive(:options).and_return({:retry_timeout => 60, :retry_interval => 60})
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 10
|
9
|
-
- 12
|
10
|
-
version: 0.10.12
|
4
|
+
prerelease:
|
5
|
+
version: 0.10.13
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Lee Kirchhoff
|
@@ -17,124 +12,88 @@ autorequire:
|
|
17
12
|
bindir: bin
|
18
13
|
cert_chain: []
|
19
14
|
|
20
|
-
date:
|
21
|
-
default_executable:
|
15
|
+
date: 2013-02-07 00:00:00 Z
|
22
16
|
dependencies:
|
23
17
|
- !ruby/object:Gem::Dependency
|
24
|
-
|
18
|
+
name: right_support
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
20
|
none: false
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 3
|
33
24
|
version: "1.3"
|
34
25
|
- - <
|
35
26
|
- !ruby/object:Gem::Version
|
36
|
-
hash: 7
|
37
|
-
segments:
|
38
|
-
- 3
|
39
|
-
- 0
|
40
27
|
version: "3.0"
|
41
|
-
requirement: *id001
|
42
|
-
name: right_support
|
43
|
-
prerelease: false
|
44
28
|
type: :runtime
|
29
|
+
prerelease: false
|
30
|
+
version_requirements: *id001
|
45
31
|
- !ruby/object:Gem::Dependency
|
46
|
-
|
32
|
+
name: right_amqp
|
33
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
47
34
|
none: false
|
48
35
|
requirements:
|
49
36
|
- - ~>
|
50
37
|
- !ruby/object:Gem::Version
|
51
|
-
hash: 13
|
52
|
-
segments:
|
53
|
-
- 0
|
54
|
-
- 3
|
55
38
|
version: "0.3"
|
56
|
-
requirement: *id002
|
57
|
-
name: right_amqp
|
58
|
-
prerelease: false
|
59
39
|
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: *id002
|
60
42
|
- !ruby/object:Gem::Dependency
|
61
|
-
|
43
|
+
name: json
|
44
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
62
45
|
none: false
|
63
46
|
requirements:
|
64
47
|
- - ~>
|
65
48
|
- !ruby/object:Gem::Version
|
66
|
-
hash: 7
|
67
|
-
segments:
|
68
|
-
- 1
|
69
|
-
- 4
|
70
49
|
version: "1.4"
|
71
|
-
requirement: *id003
|
72
|
-
name: json
|
73
|
-
prerelease: false
|
74
50
|
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: *id003
|
75
53
|
- !ruby/object:Gem::Dependency
|
76
|
-
|
54
|
+
name: eventmachine
|
55
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
77
56
|
none: false
|
78
57
|
requirements:
|
79
58
|
- - ~>
|
80
59
|
- !ruby/object:Gem::Version
|
81
|
-
hash: 59
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
- 12
|
85
|
-
- 10
|
86
60
|
version: 0.12.10
|
87
|
-
requirement: *id004
|
88
|
-
name: eventmachine
|
89
|
-
prerelease: false
|
90
61
|
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: *id004
|
91
64
|
- !ruby/object:Gem::Dependency
|
92
|
-
|
65
|
+
name: right_popen
|
66
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
93
67
|
none: false
|
94
68
|
requirements:
|
95
69
|
- - ~>
|
96
70
|
- !ruby/object:Gem::Version
|
97
|
-
hash: 1
|
98
|
-
segments:
|
99
|
-
- 1
|
100
|
-
- 0
|
101
|
-
- 11
|
102
71
|
version: 1.0.11
|
103
|
-
requirement: *id005
|
104
|
-
name: right_popen
|
105
|
-
prerelease: false
|
106
72
|
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: *id005
|
107
75
|
- !ruby/object:Gem::Dependency
|
108
|
-
|
76
|
+
name: msgpack
|
77
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
109
78
|
none: false
|
110
79
|
requirements:
|
111
80
|
- - "="
|
112
81
|
- !ruby/object:Gem::Version
|
113
|
-
hash: 7
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
- 4
|
117
|
-
- 4
|
118
82
|
version: 0.4.4
|
119
|
-
requirement: *id006
|
120
|
-
name: msgpack
|
121
|
-
prerelease: false
|
122
83
|
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: *id006
|
123
86
|
- !ruby/object:Gem::Dependency
|
124
|
-
|
87
|
+
name: net-ssh
|
88
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
125
89
|
none: false
|
126
90
|
requirements:
|
127
91
|
- - ~>
|
128
92
|
- !ruby/object:Gem::Version
|
129
|
-
hash: 3
|
130
|
-
segments:
|
131
|
-
- 2
|
132
|
-
- 0
|
133
93
|
version: "2.0"
|
134
|
-
requirement: *id007
|
135
|
-
name: net-ssh
|
136
|
-
prerelease: false
|
137
94
|
type: :runtime
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: *id007
|
138
97
|
description: |
|
139
98
|
RightAgent provides a foundation for running an agent on a server to interface
|
140
99
|
in a secure fashion with other agents in the RightScale system. A RightAgent
|
@@ -298,7 +257,6 @@ files:
|
|
298
257
|
- spec/spec.win32.opts
|
299
258
|
- spec/spec_helper.rb
|
300
259
|
- spec/tracer_spec.rb
|
301
|
-
has_rdoc: true
|
302
260
|
homepage: https://github.com/rightscale/right_agent
|
303
261
|
licenses: []
|
304
262
|
|
@@ -315,25 +273,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
273
|
requirements:
|
316
274
|
- - ">="
|
317
275
|
- !ruby/object:Gem::Version
|
318
|
-
hash: 57
|
319
|
-
segments:
|
320
|
-
- 1
|
321
|
-
- 8
|
322
|
-
- 7
|
323
276
|
version: 1.8.7
|
324
277
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
325
278
|
none: false
|
326
279
|
requirements:
|
327
280
|
- - ">="
|
328
281
|
- !ruby/object:Gem::Version
|
329
|
-
hash:
|
282
|
+
hash: 2192797536970431426
|
330
283
|
segments:
|
331
284
|
- 0
|
332
285
|
version: "0"
|
333
286
|
requirements: []
|
334
287
|
|
335
288
|
rubyforge_project:
|
336
|
-
rubygems_version: 1.
|
289
|
+
rubygems_version: 1.8.11
|
337
290
|
signing_key:
|
338
291
|
specification_version: 3
|
339
292
|
summary: Agent for interfacing server with RightScale system
|