From e2d793cfd94275cce00ea32197e36c3ecc7f0491 Mon Sep 17 00:00:00 2001 From: fwkz Date: Tue, 21 May 2019 13:27:19 +0200 Subject: [PATCH] Fix restart attempts of `restart` stanza. Number of restarts during 2nd interval is off by one. --- client/allocrunner/taskrunner/restarts/restarts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/allocrunner/taskrunner/restarts/restarts.go b/client/allocrunner/taskrunner/restarts/restarts.go index e46d30312a02..9cb6d789d5b3 100644 --- a/client/allocrunner/taskrunner/restarts/restarts.go +++ b/client/allocrunner/taskrunner/restarts/restarts.go @@ -169,8 +169,6 @@ func (r *RestartTracker) GetState() (string, time.Duration) { return structs.TaskNotRestarting, 0 } - r.count++ - // Check if we have entered a new interval. end := r.startTime.Add(r.policy.Interval) now := time.Now() @@ -179,6 +177,8 @@ func (r *RestartTracker) GetState() (string, time.Duration) { r.startTime = now } + r.count++ + // Handle restarts due to failures if !r.failure { return "", 0