Skip to content

Commit 48f2c7a

Browse files
authored
fix: remove initial delay on restart (#5419)
restarting the agent on rollback uses an exponential backoff for retries but the initial wait starts before the first retry causing a 5s delay on every restart/rollback this is particularly problematic in tests update the code to use exponential rollback strting from the first retry TestRollback time went from 36.281s to 6.263s
1 parent 590c506 commit 48f2c7a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/pkg/agent/application/upgrade/rollback.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ func restartAgent(ctx context.Context, log *logger.Logger, c client.Client) erro
201201
root, _ := utils.HasRoot() // error ignored
202202

203203
for restartAttempt := 1; restartAttempt <= maxRestartCount; restartAttempt++ {
204-
backExp.Wait()
204+
// only use exp backoff when retrying
205+
if restartAttempt != 1 {
206+
backExp.Wait()
207+
}
205208
log.Infof("Restarting Agent via control protocol; attempt %d of %d", restartAttempt, maxRestartCount)
206209
// First, try to restart Agent by sending a restart command
207210
// to its daemon (via GRPC).

0 commit comments

Comments
 (0)