chore: Rename context in `cli/agent` (#4422)

Rename context from common `ctx` to `retryCtx` to avoid later re-use.

Also kind of a bug-fix since client post was using `cmd.Context()`.
This commit is contained in:
Mathias Fredriksson 2022-10-07 21:06:20 +03:00 committed by GitHub
parent 50966c4cf7
commit 3ad27b547f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -168,15 +168,15 @@ func workspaceAgent() *cobra.Command {
}
}
ctx, cancelFunc := context.WithTimeout(cmd.Context(), time.Hour)
defer cancelFunc()
for retry.New(100*time.Millisecond, 5*time.Second).Wait(ctx) {
err := client.PostWorkspaceAgentVersion(cmd.Context(), version)
retryCtx, cancelRetry := context.WithTimeout(cmd.Context(), time.Hour)
defer cancelRetry()
for retrier := retry.New(100*time.Millisecond, 5*time.Second); retrier.Wait(retryCtx); {
err := client.PostWorkspaceAgentVersion(retryCtx, version)
if err != nil {
logger.Warn(cmd.Context(), "post agent version: %w", slog.Error(err), slog.F("version", version))
logger.Warn(retryCtx, "post agent version: %w", slog.Error(err), slog.F("version", version))
continue
}
logger.Info(ctx, "updated agent version", slog.F("version", version))
logger.Info(retryCtx, "updated agent version", slog.F("version", version))
break
}