right_chimp 2.1.25.2 → 2.1.26
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/CHANGES +5 -0
- data/Gemfile.lock +1 -1
- data/lib/right_chimp/Chimp.rb +30 -18
- data/lib/right_chimp/exec/ExecRightScript.rb +2 -1
- data/lib/right_chimp/exec/Executor.rb +12 -2
- data/lib/right_chimp/queue/ChimpQueue.rb +1 -0
- data/lib/right_chimp/queue/ExecutionGroup.rb +9 -3
- data/lib/right_chimp/queue/QueueWorker.rb +11 -5
- data/lib/right_chimp/resources/Executable.rb +4 -5
- data/lib/right_chimp/resources/Task.rb +2 -2
- data/lib/right_chimp/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13cfa3ea1acbbd9d6efb16a1669723e8bd54e92c
|
4
|
+
data.tar.gz: 7ea4f5f61e66653e385ffa828eab2b344684f3c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15dbb0cd8bcf16c882e0f8a65ca721a0ad6ebb58b693ed4182460aa234b429d9b782f0a21fb90597f47acd661b59e8751a8214b831b62291d817d0934c02ff68
|
7
|
+
data.tar.gz: 4dcdb39a3cbab65cb168e844c5ec01a0727bc361f7cabd88acfcfc922b1778727090e4c4012629790c6e006f28f86e705bdd768972f49ddf96b4ed315bcfea4b
|
data/.rubocop.yml
ADDED
data/CHANGES
CHANGED
data/Gemfile.lock
CHANGED
data/lib/right_chimp/Chimp.rb
CHANGED
@@ -269,7 +269,9 @@ module Chimp
|
|
269
269
|
|
270
270
|
script_number = File.basename(@script)
|
271
271
|
|
272
|
-
s=Executable.new
|
272
|
+
s = Executable.new
|
273
|
+
s.delay = @delay
|
274
|
+
|
273
275
|
s.params['right_script']['href']="right_script_href=/api/right_scripts/"+script_number
|
274
276
|
#Make an 1.5 call to extract name, by loading resource.
|
275
277
|
Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call : client.resource(#{s.params['right_script']['href'].scan(/=(.*)/).last.last})"
|
@@ -715,7 +717,7 @@ module Chimp
|
|
715
717
|
if self.job_uuid.nil?
|
716
718
|
self.job_uuid = ""
|
717
719
|
end
|
718
|
-
Log.warn "["+self.job_uuid+"]\"#{@script_to_run.params['right_script']['name']}\" is not a common operational script!"
|
720
|
+
Log.warn "["+self.job_uuid+"] \"#{@script_to_run.params['right_script']['name']}\" is not a common operational script!"
|
719
721
|
return @script_to_run
|
720
722
|
end
|
721
723
|
end
|
@@ -917,6 +919,7 @@ module Chimp
|
|
917
919
|
:job_notes => @job_notes,
|
918
920
|
:inputs => @inputs,
|
919
921
|
:timeout => @timeout,
|
922
|
+
:delay => @delay,
|
920
923
|
:verbose => @@verbose,
|
921
924
|
:quiet => @@quiet
|
922
925
|
)
|
@@ -1131,22 +1134,31 @@ module Chimp
|
|
1131
1134
|
Log.error '[' + job_uuid + '] Run manually!'
|
1132
1135
|
Log.error '##################################################'
|
1133
1136
|
return []
|
1137
|
+
elsif @servers.first.nil? || @executable.nil?
|
1138
|
+
Log.warn "[#{Chimp.get_job_uuid}] Nothing to do for \"chimp #{@cli_args}\"."
|
1139
|
+
# decrease our counter
|
1140
|
+
ChimpDaemon.instance.queue.processing[@group].delete(job_uuid.to_sym)
|
1141
|
+
ChimpDaemon.instance.proc_counter -= 1
|
1142
|
+
return []
|
1134
1143
|
else
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1144
|
+
Log.debug "[#{Chimp.get_job_uuid}] Generating job(s)..."
|
1145
|
+
# @servers might be > 1, but we might be using limit_start
|
1146
|
+
number_of_servers = if @limit_start.to_i > 0 || @limit_end.to_i > 0
|
1147
|
+
@limit_end.to_i - @limit_start.to_i
|
1148
|
+
else
|
1149
|
+
# reminder, we already are accounting for at least 1
|
1150
|
+
@servers.size - 1
|
1151
|
+
end
|
1152
|
+
Log.debug 'Increasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s + ') + ' +
|
1153
|
+
number_of_servers.to_s + ' for group ' + @group.to_s
|
1154
|
+
|
1155
|
+
ChimpDaemon.instance.queue.processing[@group][job_uuid.to_sym] += number_of_servers
|
1156
|
+
ChimpDaemon.instance.proc_counter += number_of_servers
|
1157
|
+
|
1158
|
+
Log.debug 'Processing counter now (' + ChimpDaemon.instance.proc_counter.to_s + ') for group ' +
|
1159
|
+
@group.to_s
|
1160
|
+
|
1161
|
+
return generate_jobs(@servers, @server_template, @executable)
|
1150
1162
|
end
|
1151
1163
|
end
|
1152
1164
|
|
@@ -1159,7 +1171,7 @@ module Chimp
|
|
1159
1171
|
d = default ? 'y' : 'n'
|
1160
1172
|
until %w[y n].include? a
|
1161
1173
|
a = ask("#{prompt} #{s} ") { |q| q.limit = 1; q.case = :downcase }
|
1162
|
-
a = d if a.length
|
1174
|
+
a = d if a.length.zero?
|
1163
1175
|
end
|
1164
1176
|
a == 'y'
|
1165
1177
|
end
|
@@ -19,6 +19,7 @@ module Chimp
|
|
19
19
|
task.tasker = @server.run_executable(@exec, options)
|
20
20
|
@audit_entry_url = task.friendly_url
|
21
21
|
task.wait_for_state('completed', @timeout)
|
22
|
+
|
22
23
|
@results = task.state
|
23
24
|
@audit_entry_data = task.details
|
24
25
|
end
|
@@ -33,7 +34,7 @@ module Chimp
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def target
|
36
|
-
|
37
|
+
@server.nickname
|
37
38
|
end
|
38
39
|
|
39
40
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
module Chimp
|
6
6
|
class Executor
|
7
|
-
attr_accessor :server, :array, :exec, :inputs, :template, :owner, :group,
|
7
|
+
attr_accessor :server, :array, :exec, :inputs, :template, :owner, :group, :delay,
|
8
8
|
:job_id, :job_uuid, :job_notes, :status, :dry_run, :verbose, :quiet, :timeout,
|
9
9
|
:retry_count, :retry_sleep, :time_start, :time_end, :error
|
10
10
|
|
@@ -36,6 +36,8 @@ module Chimp
|
|
36
36
|
@retry_sleep = h[:retry_sleep].to_i || 30
|
37
37
|
@timeout = h[:timeout].to_i || 3600
|
38
38
|
|
39
|
+
@delay = h[:delay].to_i || 0
|
40
|
+
|
39
41
|
@error = nil
|
40
42
|
@status = STATUS_NONE
|
41
43
|
@owner = nil
|
@@ -104,6 +106,14 @@ module Chimp
|
|
104
106
|
#
|
105
107
|
def run_with_retry(&block)
|
106
108
|
Log.debug "Running job '#{@job_id}' with status '#{@status}'"
|
109
|
+
# If we are not the first job in this group, wait @delay
|
110
|
+
ChimpDaemon.instance.semaphore.synchronize do
|
111
|
+
if @group.started >= ChimpQueue.instance.max_threads && @delay.nonzero?
|
112
|
+
Log.info "[#{@job_uuid}] Sleeping #{@delay} seconds between tasks"
|
113
|
+
sleep @delay
|
114
|
+
end
|
115
|
+
@group.started += 1
|
116
|
+
end
|
107
117
|
|
108
118
|
@status = STATUS_RUNNING
|
109
119
|
@time_start = Time.now
|
@@ -131,7 +141,7 @@ module Chimp
|
|
131
141
|
end
|
132
142
|
|
133
143
|
rescue SystemExit, Interrupt => ex
|
134
|
-
$stderr.puts
|
144
|
+
$stderr.puts 'Exiting!'
|
135
145
|
raise ex
|
136
146
|
|
137
147
|
rescue Interrupt => ex
|
@@ -22,7 +22,7 @@ module Chimp
|
|
22
22
|
# should be used directly.
|
23
23
|
#
|
24
24
|
class ExecutionGroup
|
25
|
-
attr_accessor :group_id, :description, :concurrency
|
25
|
+
attr_accessor :group_id, :description, :concurrency, :started
|
26
26
|
attr_reader :time_start, :time_end
|
27
27
|
|
28
28
|
def initialize(new_group_id=nil)
|
@@ -33,6 +33,7 @@ module Chimp
|
|
33
33
|
@time_start = nil
|
34
34
|
@time_end = nil
|
35
35
|
@concurrency = 1
|
36
|
+
@started = 0
|
36
37
|
end
|
37
38
|
|
38
39
|
#
|
@@ -271,11 +272,16 @@ module Chimp
|
|
271
272
|
#
|
272
273
|
class SerialExecutionGroup < ExecutionGroup
|
273
274
|
def ready?
|
274
|
-
|
275
|
+
# Make sure only one thread makes the ready question at the same time,
|
276
|
+
# otherwise we can run into race conditions. This is critical for SerialExecutionGroup
|
277
|
+
ChimpDaemon.instance.semaphore.synchronize do
|
278
|
+
ready = get_jobs_by_status(Executor::STATUS_RUNNING).size == 0 && get_jobs_by_status(Executor::STATUS_NONE).size > 0
|
279
|
+
return ready
|
280
|
+
end
|
275
281
|
end
|
276
282
|
|
277
283
|
def short_name
|
278
|
-
|
284
|
+
'S'
|
279
285
|
end
|
280
286
|
end
|
281
287
|
|
@@ -22,6 +22,7 @@ module Chimp
|
|
22
22
|
|
23
23
|
begin
|
24
24
|
if work_item != nil
|
25
|
+
|
25
26
|
job_uuid = work_item.job_uuid
|
26
27
|
group = work_item.group.group_id
|
27
28
|
|
@@ -29,19 +30,25 @@ module Chimp
|
|
29
30
|
work_item.owner = Thread.current.object_id
|
30
31
|
|
31
32
|
ChimpDaemon.instance.semaphore.synchronize do
|
32
|
-
# remove from the processing queue
|
33
|
-
Log.debug 'Decreasing processing counter (' + (ChimpDaemon.instance.proc_counter-1).to_s + ') for [' + job_uuid.to_s + '] group: ' + group.to_s
|
34
33
|
# only do this if we are running with chimpd
|
35
34
|
if ChimpDaemon.instance.queue.processing[group].nil?
|
36
35
|
# no op
|
37
36
|
else
|
38
|
-
|
39
|
-
Log.debug ChimpDaemon.instance.queue.processing[group].inspect
|
37
|
+
# remove from the processing queue
|
40
38
|
if ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] == 0
|
41
39
|
Log.debug 'Completed processing task ' + job_uuid.to_s
|
40
|
+
Log.debug 'Deleting ' + job_uuid.to_s
|
42
41
|
ChimpDaemon.instance.queue.processing[group].delete(job_uuid.to_sym)
|
43
42
|
Log.debug ChimpDaemon.instance.queue.processing.inspect
|
44
43
|
else
|
44
|
+
Log.debug 'Decreasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s +
|
45
|
+
') for [' + job_uuid.to_s + '] group: ' + group.to_s
|
46
|
+
|
47
|
+
ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] -= 1
|
48
|
+
|
49
|
+
Log.debug 'Processing counter now (' + ChimpDaemon.instance.proc_counter.to_s +
|
50
|
+
') for [' + job_uuid.to_s + '] group: ' + group.to_s
|
51
|
+
Log.debug ChimpDaemon.instance.queue.processing[group].inspect
|
45
52
|
Log.debug 'Still counting down for ' + job_uuid.to_s
|
46
53
|
end
|
47
54
|
ChimpDaemon.instance.proc_counter -= 1
|
@@ -49,7 +56,6 @@ module Chimp
|
|
49
56
|
end
|
50
57
|
|
51
58
|
work_item.run
|
52
|
-
sleep @delay
|
53
59
|
else
|
54
60
|
sleep 1
|
55
61
|
end
|
@@ -6,9 +6,7 @@ module Chimp
|
|
6
6
|
# This task contains parameters that describe a script/task to be executed
|
7
7
|
#
|
8
8
|
class Executable
|
9
|
-
|
10
|
-
attr_writer :params
|
11
|
-
attr_reader :params
|
9
|
+
attr_accessor :params, :delay
|
12
10
|
|
13
11
|
def initialize
|
14
12
|
@params = {
|
@@ -23,9 +21,10 @@ module Chimp
|
|
23
21
|
"name"=>"dummy_name",
|
24
22
|
"description"=>"dummy_description"
|
25
23
|
},
|
26
|
-
|
27
|
-
|
24
|
+
"recipe"=>nil,
|
25
|
+
"apply"=>"operational"
|
28
26
|
}
|
27
|
+
@delay = 0
|
29
28
|
end
|
30
29
|
|
31
30
|
def href
|
@@ -13,11 +13,11 @@ module Chimp
|
|
13
13
|
def wait_for_state(desired_state, timeout=900)
|
14
14
|
while(timeout > 0)
|
15
15
|
state=self.tasker.show.summary
|
16
|
-
|
16
|
+
return true if self.state.match(desired_state)
|
17
17
|
friendly_url = Connection.audit_url + '/audit_entries/'
|
18
18
|
friendly_url += self.href.split(/\//).last
|
19
19
|
friendly_url = friendly_url.gsub('ae-', '')
|
20
|
-
raise "FATAL error, #{tasker.show.summary}\n\n Audit: #{friendly_url}
|
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
|
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.26
|
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-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -132,6 +132,7 @@ extensions: []
|
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
134
|
- ".gitignore"
|
135
|
+
- ".rubocop.yml"
|
135
136
|
- ".travis.yml"
|
136
137
|
- CHANGES
|
137
138
|
- Gemfile
|
@@ -200,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
201
|
version: '0'
|
201
202
|
requirements: []
|
202
203
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.6.7
|
204
205
|
signing_key:
|
205
206
|
specification_version: 4
|
206
207
|
summary: RightScale platform command-line tool
|