diff options
author | Mike Bryant <m@ocado.com> | 2016-01-27 14:42:58 +0000 |
---|---|---|
committer | Mike Bryant <m@ocado.com> | 2016-01-27 14:42:58 +0000 |
commit | 8cef62390cdfbff723e2d6b99fd92157406e17d5 (patch) | |
tree | 3abb49e7ca9ba3a4756f62a177f52fd6c51087cc | |
parent | 624bea144523777c1830f307ecfd218fc927caeb (diff) |
If a reload operation changes the number of nodes, ensure @durations is updated
Otherwise the average duration calculation will be wrong
-rw-r--r-- | lib/oxidized/jobs.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb index 60a83f4..2c656f6 100644 --- a/lib/oxidized/jobs.rb +++ b/lib/oxidized/jobs.rb @@ -20,6 +20,11 @@ module Oxidized end def duration last + if @durations.size > @nodes.size + @durations.slice! @nodes.size...@durations.size + elsif @durations.size < @nodes.size + @durations.fill AVERAGE_DURATION, @durations.size...@nodes.size + end @durations.push(last).shift @duration = @durations.inject(:+).to_f / @nodes.size #rolling average new_count |