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)
This commit is contained in:
Harshavardhana
2022-07-02 08:45:00 -07:00
committed by GitHub
parent 82a6c4f20f
commit 58860ccb15
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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)
}
}
}
+2 -1
View File
@@ -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)
}
}
}