summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2018-05-03 09:10:28 -0700
committerGitHub <noreply@github.com>2018-05-03 09:10:28 -0700
commit18fababce79cdf8ccde446dfa024ab060a07e219 (patch)
tree0a91951fd1a6e7484541fc742893ab5e6af4b709
parentba1226882e6a4f3e5a5da88528620148e2b399c4 (diff)
parentca4aa7c815c5ec9880c0b141cbe8e02f51406b7b (diff)
Merge pull request #1327 from jsynack/qf-nodehooks-desync
Quick-fix: repair some logic for @jobs_done.
-rw-r--r--lib/oxidized/worker.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb
index 692b060..5d5fc01 100644
--- a/lib/oxidized/worker.rb
+++ b/lib/oxidized/worker.rb
@@ -42,9 +42,9 @@ module Oxidized
node.stats.add job
@jobs.duration job.time
node.running = false
- @jobs_done += 1 # needed for worker_done event
if job.status == :success
+ @jobs_done += 1 # needed for :nodes_done hook
Oxidized.Hooks.handle :node_success, :node => node,
:job => job
msg = "update #{node.name}"
@@ -66,6 +66,11 @@ module Oxidized
msg += ", retry attempt #{node.retry}"
@nodes.next node.name
else
+ # Only increment the @jobs_done when we give up retries for a node (or success).
+ # As it would otherwise cause @jobs_done to be incremented with generic retries.
+ # This would cause :nodes_done hook to desync from running at the end of the nodelist and
+ # be fired when the @jobs_done > @nodes.count (could be mid-cycle on the next cycle).
+ @jobs_done += 1
msg += ", retries exhausted, giving up"
node.retry = 0
Oxidized.Hooks.handle :node_fail, :node => node,