summaryrefslogtreecommitdiff
path: root/lib/oxidized/worker.rb
diff options
context:
space:
mode:
authorWild Kat <wk@users.noreply.github.com>2018-05-26 23:49:29 +0200
committerGitHub <noreply@github.com>2018-05-26 23:49:29 +0200
commit39dbb74c527c054007e26ad34c8921d4be6cb638 (patch)
treed55745153153450fb40e1f591eb861495a6068d9 /lib/oxidized/worker.rb
parentdefdc69f92b3bcf62b1fd3b5ceac63a7a4e637ae (diff)
parent42bf10b7bce34ff577c469f6c2f659f3913cbf4a (diff)
Merge branch 'master' into FortiOS-Push
Diffstat (limited to 'lib/oxidized/worker.rb')
-rw-r--r--lib/oxidized/worker.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb
index 4173680..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}"
@@ -52,7 +52,7 @@ module Oxidized
msg += " with message '#{node.msg}'" if node.msg
output = node.output.new
if output.store node.name, job.config,
- :msg => msg, :email => node.email, :user => node.user, :group => node.group
+ :msg => msg, :email => node.email, :user => node.user, :group => node.group
Oxidized.logger.info "Configuration updated for #{node.group}/#{node.name}"
Oxidized.Hooks.handle :post_store, :node => node,
:job => job,
@@ -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,
@@ -80,7 +85,11 @@ module Oxidized
private
def is_cycle_finished?
- @jobs_done > 0 && @jobs_done % @nodes.count == 0
+ if @jobs_done > @nodes.count
+ true
+ else
+ @jobs_done > 0 && @jobs_done % @nodes.count == 0
+ end
end
def run_done_hook