right_chimp 2.1.24 → 2.1.25

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b8353c389aaf578df02f964a87778706144628b
4
- data.tar.gz: 42bae4bf2b3e4246cf5ee31fea1709e42a3be2d7
3
+ metadata.gz: 6c548668e38fd58794b473964f7ba204a7e75892
4
+ data.tar.gz: 195e3977c81913af9ffd816f607901fa83150557
5
5
  SHA512:
6
- metadata.gz: a60272b66e310894fdbbc393b5010dd12eeb9380c65aeeea84c5d152390edbf8a7f7a5330aea4188c2e8a4dd747b4502656278cac1ba4e29d71d22f6c3956559
7
- data.tar.gz: 8edc1310533df69e7a192019c77aca13a799f529bc5b07de5eb0f7ea3af9d02a7b46cbb8efc796ab4b3f8fcf380a54f73252eacf1b4a7d704da1f61e3420ee47
6
+ metadata.gz: bec51a0eea3e14118a9a72f6df1218339ffc0885c127e34fe0c6574c8e422c8857bd3e3a8b440fe47fa12bdde8810323c42baf19cf55c0b5dc706cecfcead239
7
+ data.tar.gz: 0445c453033f4371afc70d7e2a8ada37bb7e51e3de8e358577719d275f57daa3556dde1d898348f851dbabc2672a91b3f570bf5a132a36cbb6546705bc4ea77a
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ Version 2.1.25
2
+ --------------
3
+ * Bugfix: Fixed some corner case race conditions that affected the proper tracking of processing tasks.
1
4
  Version 2.1.24
2
5
  --------------
3
6
  * Feature: We now ensure jobs are added and tracked into the processing status before sending a 200 back to
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- right_chimp (2.1.24)
4
+ right_chimp (2.1.25)
5
5
  highline (~> 1.7.2)
6
6
  nokogiri (~> 1.6.7.1)
7
7
  progressbar (~> 0.11.0)
@@ -68,4 +68,4 @@ DEPENDENCIES
68
68
  rspec (~> 2.6.0)
69
69
 
70
70
  BUNDLED WITH
71
- 1.12.5
71
+ 1.13.1
@@ -1103,7 +1103,6 @@ module Chimp
1103
1103
  # This is used by chimpd, when processing a task.
1104
1104
  #
1105
1105
  def process
1106
-
1107
1106
  Chimp.set_failure(false)
1108
1107
  Chimp.set_job_uuid(job_uuid)
1109
1108
 
@@ -1123,12 +1122,6 @@ module Chimp
1123
1122
  get_executable_info unless Chimp.failure
1124
1123
 
1125
1124
  # All elements of task have been processed
1126
- ChimpDaemon.instance.semaphore.synchronize do
1127
- # remove from the processing queue
1128
- Log.debug 'Removing job: ' + job_uuid + ' from the processing queue for group: ' + group.to_s
1129
- ChimpDaemon.instance.queue.processing[group].delete(job_uuid)
1130
- ChimpDaemon.instance.proc_counter -= 1
1131
- end
1132
1125
 
1133
1126
  if Chimp.failure
1134
1127
 
@@ -1139,11 +1132,19 @@ module Chimp
1139
1132
  Log.error '##################################################'
1140
1133
  return []
1141
1134
  else
1142
- if @servers.first.nil? or @executable.nil?
1135
+ if @servers.first.nil? || @executable.nil?
1143
1136
  Log.warn "[#{Chimp.get_job_uuid}] Nothing to do for \"chimp #{@cli_args}\"."
1137
+ # decrease our counter
1138
+ ChimpDaemon.instance.queue.processing[@group].delete(job_uuid.to_sym)
1139
+ ChimpDaemon.instance.proc_counter -= 1
1144
1140
  return []
1145
1141
  else
1146
- Log.debug "[#{Chimp.get_job_uuid}] Generating job..."
1142
+ Log.debug "[#{Chimp.get_job_uuid}] Generating job(s)..."
1143
+ Log.debug 'Increasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s + ") + " + @servers.size.to_s + ' for group ' + @group.to_s
1144
+
1145
+ ChimpDaemon.instance.queue.processing[@group][job_uuid.to_sym] += @servers.size
1146
+ ChimpDaemon.instance.proc_counter += @servers.size - 1
1147
+
1147
1148
  return generate_jobs(@servers, @server_template, @executable)
1148
1149
  end
1149
1150
  end
@@ -1174,7 +1175,6 @@ module Chimp
1174
1175
  begin
1175
1176
  while !@dry_run
1176
1177
  local_queue = ChimpQueue.instance
1177
-
1178
1178
  #
1179
1179
  # load up remote chimpd jobs into the local queue
1180
1180
  # this makes all the standard queue control methods available to us
@@ -89,9 +89,9 @@ module Chimp
89
89
  when '--help', '-h'
90
90
  help
91
91
  when '--exit', '-x'
92
- uri = "http://localhost:#{@port}/admin"
93
- response = RestClient.post uri, { 'shutdown' => true }.to_yaml
94
- exit 0
92
+ uri = "http://localhost:#{@port}/admin"
93
+ response = RestClient.post uri, { 'shutdown' => true }.to_yaml
94
+ exit 0
95
95
  end
96
96
  end
97
97
  rescue GetoptLong::InvalidOption => ex
@@ -341,6 +341,7 @@ module Chimp
341
341
  # /group/<name>/<status>
342
342
  #
343
343
  def do_GET(req, resp)
344
+
344
345
  jobs = []
345
346
  Log.debug 'get group info'
346
347
 
@@ -362,10 +363,11 @@ module Chimp
362
363
  jobs = g.get_jobs_by_status(filter) if g
363
364
 
364
365
  # If there are processing jobs, add them as dummy executions.
365
- if g2
366
+ if g2 && !g2.empty?
367
+
366
368
  Log.debug 'Group: ' + group_name + ' is processing:'
367
369
  g2.each do |job|
368
- Log.debug 'Job: ' + job
370
+ Log.debug 'Job: ' + job.to_s
369
371
  j = ExecRightScript.new(group: group_name, job_uuid: job)
370
372
  jobs.push j
371
373
  end
@@ -429,20 +431,26 @@ module Chimp
429
431
  # Ask chimpd to process a Chimp object directly
430
432
  #
431
433
  if verb == 'process' or verb == 'add'
432
- # comment the next line to GET STUCK IN PROCESSING forever
433
- ChimpDaemon.instance.chimp_queue.push payload
434
434
  ChimpDaemon.instance.semaphore.synchronize do
435
435
  # While we are at it, we will store these processing jobs to prevent issues in the event
436
436
  # of a very slow API response.
437
437
  Log.debug 'Adding job: ' + job_uuid + ' to the processing queue for group: ' + group.to_s
438
- q.processing[payload.group] = [] if q.processing[payload.group].nil?
439
- q.processing[payload.group].push(payload.job_uuid)
438
+
439
+ q.processing[payload.group] = {} if q.processing[payload.group].nil?
440
+ q.processing[payload.group][payload.job_uuid.to_sym] = 0
440
441
 
441
442
  ChimpDaemon.instance.proc_counter += 1
442
443
  end
444
+ # comment the next line to GET STUCK IN PROCESSING forever
445
+ ChimpDaemon.instance.chimp_queue.push payload
443
446
 
444
- Log.debug 'Tasks in the processing queue:' + ChimpDaemon.instance.proc_counter.to_s
445
- Log.debug 'Pocessing:'
447
+ # Proper count of processing Tasks
448
+ counter = 0
449
+ q.processing.each{|k,v|
450
+ counter += v.size
451
+ }
452
+ Log.debug 'Processing:'
453
+ Log.debug 'Tasks in the processing queue:' + counter.to_s
446
454
  Log.debug q.processing.inspect
447
455
  elsif verb == 'update'
448
456
  puts 'UPDATE'
@@ -571,7 +579,7 @@ module Chimp
571
579
  stats << "waiting: #{queue.get_jobs_by_status(:none).size} / "
572
580
  stats << "failed: #{queue.get_jobs_by_status(:error).size} / "
573
581
  stats << "done: #{queue.get_jobs_by_status(:done).size} / "
574
- stats << "processing: #{ChimpDaemon.instance.proc_counter.to_i} / "
582
+ stats << "processing: #{ChimpDaemon.instance.proc_counter} / "
575
583
  stats << "\n"
576
584
 
577
585
  resp.body = stats
@@ -587,7 +595,7 @@ module Chimp
587
595
  "waiting" => queue.get_jobs_by_status(:none).size,
588
596
  "failed" => queue.get_jobs_by_status(:error).size,
589
597
  "done" => queue.get_jobs_by_status(:done).size,
590
- "processing" => ChimpDaemon.instance.proc_counter.to_i,
598
+ "processing" => ChimpDaemon.instance.proc_counter,
591
599
  "holding" => queue.get_jobs_by_status(:holding).size
592
600
  }
593
601
 
@@ -22,8 +22,27 @@ module Chimp
22
22
 
23
23
  begin
24
24
  if work_item != nil
25
+ job_uuid = work_item.job_uuid
26
+ group = work_item.group.group_id
27
+
25
28
  work_item.retry_count = @retry_count
26
29
  work_item.owner = Thread.current.object_id
30
+ ChimpDaemon.instance.semaphore.synchronize do
31
+ # remove from the processing queue
32
+ Log.debug 'Decreasing processing counter (' + (ChimpDaemon.instance.proc_counter-1).to_s + ') for [' + job_uuid + '] group: ' + group.to_s
33
+ ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] -= 1
34
+ Log.debug ChimpDaemon.instance.queue.processing[group].inspect
35
+ if ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] == 0
36
+ Log.debug 'Completed processing task ' + job_uuid
37
+ ChimpDaemon.instance.queue.processing[group].delete(job_uuid.to_sym)
38
+ Log.debug ChimpDaemon.instance.queue.processing.inspect
39
+ else
40
+ Log.debug 'Still counting down for ' + job_uuid
41
+ end
42
+
43
+ ChimpDaemon.instance.proc_counter -= 1
44
+ end
45
+
27
46
  work_item.run
28
47
  sleep @delay
29
48
  else
@@ -1,3 +1,3 @@
1
1
  module Chimp
2
- VERSION = "2.1.24"
2
+ VERSION = "2.1.25"
3
3
  end
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.24
4
+ version: 2.1.25
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-09-13 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake