From 58860ccb15126da5e324db163d88d7c2b30dd1a4 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 2 Jul 2022 08:45:00 -0700 Subject: [PATCH] reset timer after the function body is finished (#4143) reset timer after the function body is finished this is needed to make sure to wait "expected" amount of time, otherwise the timer has already fired (negating the wait of your function body) --- cmd/admin-service-restart.go | 4 ++-- cmd/ready.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/admin-service-restart.go b/cmd/admin-service-restart.go index a2a4b7c8..6adf3f3c 100644 --- a/cmd/admin-service-restart.go +++ b/cmd/admin-service-restart.go @@ -147,8 +147,6 @@ func mainAdminServiceRestart(ctx *cli.Context) error { case <-globalContext.Done(): return globalContext.Err() case <-timer.C: - timer.Reset(time.Second) - ctx, cancel := context.WithTimeout(globalContext, 3*time.Second) // Fetch the service status of the specified MinIO server info, e := client.ServerInfo(ctx) @@ -168,6 +166,8 @@ func mainAdminServiceRestart(ctx *cli.Context) error { default: printProgress() } + + timer.Reset(time.Second) } } } diff --git a/cmd/ready.go b/cmd/ready.go index 5d5de99c..0cf4b158 100644 --- a/cmd/ready.go +++ b/cmd/ready.go @@ -136,7 +136,6 @@ func mainReady(cliCtx *cli.Context) error { case <-ctx.Done(): return nil case <-timer.C: - timer.Reset(healthCheckInterval) healthResult, hErr := anonClient.Healthy(ctx, healthOpts) fatalIf(probe.NewError(hErr).Trace(aliasedURL), "Couldn't get the health status for `"+aliasedURL+"`.") printMsg(readyMessage{ @@ -148,6 +147,8 @@ func mainReady(cliCtx *cli.Context) error { if healthResult.Healthy { return nil } + + timer.Reset(healthCheckInterval) } } }