right_chimp 2.1.14 → 2.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +4 -0
- data/Gemfile.lock +2 -2
- data/lib/right_chimp/daemon/ChimpDaemon.rb +47 -30
- data/lib/right_chimp/daemon/ChimpDaemonClient.rb +1 -0
- data/lib/right_chimp/exec/ExecRightScript.rb +8 -7
- data/lib/right_chimp/exec/Executor.rb +8 -15
- data/lib/right_chimp/queue/ChimpQueue.rb +12 -2
- data/lib/right_chimp/resources/Task.rb +11 -4
- data/lib/right_chimp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f28fe644c07a27aea21a4cd11a7b21223bda8159
|
4
|
+
data.tar.gz: 8e1c12689609f5424d40b3835d6f0c11d0f081dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e7a74d5476dcfb2baefec3af913f834203118816e1ebfdb67fc736208e0bd5d0ccc365bed2782d2a9a86ebfa4c8367130119790efed28f4cd0778606313c50
|
7
|
+
data.tar.gz: 61e8b9ea7fd1363c3207890e8ca99f0b9be7189bd370ca0fc7f7e679d22ec3c91ece3c8f9f26e2737ac88095e5108dd5d3722cac8add253fbb6b1f77cdf156c0
|
data/CHANGES
CHANGED
@@ -156,3 +156,7 @@ Version 2.1.13
|
|
156
156
|
* Feature: Changed error reporting format
|
157
157
|
* Feature: Web UI now shows job_uuid
|
158
158
|
* Feature: One can now associate a "note" to a job by using --job-notes="foo"
|
159
|
+
|
160
|
+
Version 2.1.15
|
161
|
+
---------------
|
162
|
+
* Feature: We now are able to query a subset of job_uuids and total stats format.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
right_chimp (2.1.
|
4
|
+
right_chimp (2.1.15)
|
5
5
|
highline (~> 1.7.2)
|
6
6
|
nokogiri (~> 1.6.7.1)
|
7
7
|
progressbar (~> 0.11.0)
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
coderay (1.1.0)
|
17
17
|
debug_inspector (0.0.2)
|
18
18
|
diff-lcs (1.1.3)
|
19
|
-
domain_name (0.5.
|
19
|
+
domain_name (0.5.20160310)
|
20
20
|
unf (>= 0.0.5, < 1.0.0)
|
21
21
|
highline (1.7.8)
|
22
22
|
http-cookie (1.0.2)
|
@@ -392,6 +392,7 @@ module Chimp
|
|
392
392
|
|
393
393
|
def do_POST(req, resp)
|
394
394
|
id = -1
|
395
|
+
# we don't know the job_id because we cant guess how many tasks one call creates.
|
395
396
|
job_id = self.get_id(req)
|
396
397
|
job_uuid= self.get_job_uuid(req)
|
397
398
|
verb = self.get_verb(req)
|
@@ -405,12 +406,6 @@ module Chimp
|
|
405
406
|
#
|
406
407
|
# Ask chimpd to process a Chimp object directly
|
407
408
|
#
|
408
|
-
#if verb == 'process' or verb == 'add'
|
409
|
-
# payload.interactive = false
|
410
|
-
# tasks = payload.process
|
411
|
-
# tasks.each do |task|
|
412
|
-
# q.push(group, task)
|
413
|
-
# end
|
414
409
|
if verb == 'process' or verb == 'add'
|
415
410
|
ChimpDaemon.instance.chimp_queue.push payload
|
416
411
|
ChimpDaemon.instance.semaphore.synchronize do
|
@@ -423,10 +418,9 @@ module Chimp
|
|
423
418
|
q.get_job(job_id).status = payload.status
|
424
419
|
end
|
425
420
|
|
426
|
-
|
427
421
|
resp.body = {
|
428
422
|
'job_uuid' => job_uuid ,
|
429
|
-
'id' =>
|
423
|
+
'id' => job_id
|
430
424
|
}.to_yaml
|
431
425
|
|
432
426
|
raise WEBrick::HTTPStatus::OK
|
@@ -582,9 +576,10 @@ module Chimp
|
|
582
576
|
job_types.each do |type|
|
583
577
|
jobs[type] = queue.get_jobs_by_status(type).map do |job|
|
584
578
|
{ :id => job.job_id,
|
585
|
-
:
|
586
|
-
:
|
587
|
-
:
|
579
|
+
:uuid => job.job_uuid,
|
580
|
+
:server => job.server.name,
|
581
|
+
:script => job.info,
|
582
|
+
:audit_entry_url => job.audit_entry_url
|
588
583
|
}
|
589
584
|
end
|
590
585
|
end
|
@@ -594,35 +589,58 @@ module Chimp
|
|
594
589
|
raise WEBrick::HTTPStatus::OK
|
595
590
|
end
|
596
591
|
|
592
|
+
if req.request_uri.path =~ /jobs\.json\/id\/\d+$/
|
593
|
+
|
594
|
+
job_id = File.basename(req.request_uri.path)
|
595
|
+
queue = ChimpQueue.instance
|
596
|
+
|
597
|
+
res = queue.get_job(job_id)
|
598
|
+
|
599
|
+
case res
|
600
|
+
when ExecRightScript
|
601
|
+
|
602
|
+
result = {}
|
603
|
+
result[:id] = job_id
|
604
|
+
result[:uuid] = res.job_uuid
|
605
|
+
result[:status] = res.status
|
606
|
+
result[:server] = res.server.name
|
607
|
+
result[:script] = res.info
|
608
|
+
result[:audit_entry_url] = res.audit_entry_url
|
609
|
+
|
610
|
+
resp.body = result.to_json
|
611
|
+
end
|
612
|
+
|
613
|
+
raise WEBrick::HTTPStatus::OK
|
614
|
+
|
615
|
+
end
|
597
616
|
#
|
598
|
-
# Attempt to return just 1
|
617
|
+
# Attempt to return just 1 job_UUID data
|
599
618
|
#
|
600
|
-
if req.request_uri.path =~ /jobs\.json\/
|
619
|
+
if req.request_uri.path =~ /jobs\.json\/uuid\/*\w{6}$/
|
601
620
|
|
602
|
-
|
603
|
-
#instance the queue
|
621
|
+
uuid = File.basename(req.request_uri.path)
|
622
|
+
# instance the queue
|
604
623
|
queue = ChimpQueue.instance
|
605
624
|
|
606
|
-
|
625
|
+
res = queue.get_jobs_by_uuid(uuid)
|
626
|
+
|
627
|
+
jobs = {}
|
607
628
|
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
}
|
618
|
-
}
|
629
|
+
res.each_with_index do |r, i|
|
630
|
+
jobs[i] = { id: r.job_id,
|
631
|
+
uuid: r.job_uuid,
|
632
|
+
status: r.status,
|
633
|
+
server: r.server.name,
|
634
|
+
script: r.info,
|
635
|
+
audit_entry_url: r.audit_entry_url
|
636
|
+
}
|
637
|
+
end
|
619
638
|
|
620
|
-
resp.body =
|
639
|
+
resp.body = jobs.to_json
|
621
640
|
|
622
641
|
raise WEBrick::HTTPStatus::OK
|
623
642
|
end
|
624
643
|
|
625
|
-
|
626
644
|
#
|
627
645
|
# Check for static CSS files and serve them
|
628
646
|
#
|
@@ -663,6 +681,5 @@ module Chimp
|
|
663
681
|
end
|
664
682
|
end
|
665
683
|
end # DisplayServlet
|
666
|
-
|
667
684
|
end # ChimpDaemon
|
668
685
|
end
|
@@ -19,6 +19,7 @@ module Chimp
|
|
19
19
|
|
20
20
|
if response.code > 199 and response.code < 300
|
21
21
|
Log.debug "Response code was #{response.code}"
|
22
|
+
|
22
23
|
id = YAML::load(response.body)['id']
|
23
24
|
#ID changes upon execution, not upon submission.
|
24
25
|
job_uuid = YAML::load(response.body)['job_uuid']
|
@@ -4,35 +4,36 @@
|
|
4
4
|
module Chimp
|
5
5
|
class ExecRightScript < Executor
|
6
6
|
|
7
|
-
attr_accessor :audit_entry_data
|
7
|
+
attr_accessor :audit_entry_data, :audit_entry_url
|
8
8
|
|
9
9
|
def run
|
10
|
-
options = {:
|
10
|
+
options = { ignore_lock: true }.merge(@inputs)
|
11
11
|
|
12
12
|
if @timeout < 300
|
13
|
-
Log.error
|
13
|
+
Log.error 'timeout was less than 5 minutes! resetting to 5 minutes'
|
14
14
|
@timeout = 300
|
15
15
|
end
|
16
16
|
|
17
17
|
run_with_retry do
|
18
18
|
task=Task.new
|
19
19
|
task.tasker = @server.run_executable(@exec, options)
|
20
|
-
task.
|
20
|
+
@audit_entry_url = task.friendly_url
|
21
|
+
task.wait_for_state('completed', @timeout)
|
21
22
|
@results = task.state
|
22
23
|
@audit_entry_data = task.details
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def describe_work
|
27
|
-
|
28
|
+
"[#{@job_uuid}] ExecRightScript job_id=#{@job_id} script=\"#{@exec.params['right_script']['name']}\" server=\"#{@server.nickname}\""
|
28
29
|
end
|
29
30
|
|
30
31
|
def info
|
31
|
-
|
32
|
+
@exec.params['right_script']['name']
|
32
33
|
end
|
33
34
|
|
34
35
|
def target
|
35
|
-
|
36
|
+
@server.nickname
|
36
37
|
end
|
37
38
|
|
38
39
|
end
|
@@ -127,7 +127,7 @@ module Chimp
|
|
127
127
|
@status = STATUS_DONE
|
128
128
|
@group.job_completed
|
129
129
|
else
|
130
|
-
Log.warn "[#{@job_uuid}] Ownership of job_id #{job_id} lost. User cancelled operation?"
|
130
|
+
Log.warn "[#{@job_uuid}][#{@job_id}] Ownership of job_id #{job_id} lost. User cancelled operation?"
|
131
131
|
end
|
132
132
|
|
133
133
|
rescue SystemExit, Interrupt => ex
|
@@ -141,7 +141,7 @@ module Chimp
|
|
141
141
|
|
142
142
|
if @retry_count > 0
|
143
143
|
@status = STATUS_RETRYING
|
144
|
-
Log.error "[#{@job_uuid}] Error executing on \"#{name}\". Retrying in #{@retry_sleep} seconds..."
|
144
|
+
Log.error "[#{@job_uuid}][#{@job_id}] Error executing on \"#{name}\". Retrying in #{@retry_sleep} seconds..."
|
145
145
|
@retry_count -= 1
|
146
146
|
sleep @retry_sleep
|
147
147
|
retry
|
@@ -149,7 +149,7 @@ module Chimp
|
|
149
149
|
|
150
150
|
@status = STATUS_ERROR
|
151
151
|
@error = ex
|
152
|
-
Log.error "[#{@job_uuid}] Error executing on \"#{name}\": #{ex}"
|
152
|
+
Log.error "[#{@job_uuid}][#{@job_id}] Error executing on \"#{name}\": #{ex}"
|
153
153
|
|
154
154
|
ensure
|
155
155
|
@time_end = Time.now
|
@@ -157,18 +157,11 @@ module Chimp
|
|
157
157
|
end
|
158
158
|
|
159
159
|
rescue RuntimeError => ex
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
if @
|
164
|
-
|
165
|
-
end
|
166
|
-
if @job_notes
|
167
|
-
err += " Notes: #{@job_notes}\n"
|
168
|
-
end
|
169
|
-
Log.error "[#{@job_uuid}] Caught RuntimeError: #{err} Aborting job.\n"
|
170
|
-
#Log.error ex.inspect
|
171
|
-
#Log.error ex.backtrace
|
160
|
+
err = ex.message + "IP: #{@server.params["ip_address"]}\n" if @server.params['ip_address']
|
161
|
+
err += " Group: #{@group.group_id}\n" if @group.group_id
|
162
|
+
err += " Notes: #{@job_notes}\n" if @job_notes
|
163
|
+
err += " Notes: #{@job_notes}\n" if @job_notes
|
164
|
+
Log.error "[#{@job_uuid}][#{@job_id}] Caught RuntimeError: #{err} Job failed.\n"
|
172
165
|
@status = STATUS_ERROR
|
173
166
|
@error = ex
|
174
167
|
end
|
@@ -162,7 +162,7 @@ module Chimp
|
|
162
162
|
jobs = self.get_jobs
|
163
163
|
|
164
164
|
jobs.each do |j|
|
165
|
-
return j if j.job_id == id
|
165
|
+
return j if j.job_id == id.to_i
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
@@ -172,9 +172,19 @@ module Chimp
|
|
172
172
|
group.get_jobs.each { |job| r << job }
|
173
173
|
end
|
174
174
|
|
175
|
-
|
175
|
+
r
|
176
176
|
end
|
177
177
|
|
178
|
+
def get_jobs_by_uuid(uuid)
|
179
|
+
r = []
|
180
|
+
jobs = self.get_jobs
|
181
|
+
|
182
|
+
jobs.each do |j|
|
183
|
+
r << j if j.job_uuid == uuid
|
184
|
+
end
|
185
|
+
|
186
|
+
r
|
187
|
+
end
|
178
188
|
#############################################################
|
179
189
|
protected
|
180
190
|
|
@@ -14,10 +14,10 @@ module Chimp
|
|
14
14
|
while(timeout > 0)
|
15
15
|
state=self.tasker.show.summary
|
16
16
|
return true if self.state.match(desired_state)
|
17
|
-
friendly_url = Connection.audit_url+
|
17
|
+
friendly_url = Connection.audit_url + '/audit_entries/'
|
18
18
|
friendly_url += self.href.split(/\//).last
|
19
|
-
friendly_url = friendly_url.gsub(
|
20
|
-
raise "FATAL error, #{
|
19
|
+
friendly_url = friendly_url.gsub('ae-', '')
|
20
|
+
raise "FATAL error, #{tasker.show.summary}\n\n Audit: #{friendly_url}'\n " if self.state.match("failed")
|
21
21
|
sleep 30
|
22
22
|
timeout -= 30
|
23
23
|
end
|
@@ -25,7 +25,7 @@ module Chimp
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def wait_for_completed(timeout=900)
|
28
|
-
wait_for_state(
|
28
|
+
wait_for_state('completed', timeout)
|
29
29
|
end
|
30
30
|
|
31
31
|
def state
|
@@ -36,6 +36,13 @@ module Chimp
|
|
36
36
|
self.tasker.href
|
37
37
|
end
|
38
38
|
|
39
|
+
def friendly_url
|
40
|
+
friendly_url = Connection.audit_url+"/audit_entries/"
|
41
|
+
friendly_url += self.href.split(/\//).last
|
42
|
+
friendly_url = friendly_url.gsub("ae-","")
|
43
|
+
friendly_url
|
44
|
+
end
|
45
|
+
|
39
46
|
def details
|
40
47
|
self.tasker.show(:view => "extended").detail
|
41
48
|
end
|
data/lib/right_chimp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_chimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RightScale Operations
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|