Skip to content

chore: Rename context in cli/agent #4422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: Rename context in cli/agent
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()`.
  • Loading branch information
mafredri committed Oct 7, 2022
commit 4a5afcb09243eaff657ba7995612f087244fe1d5
12 changes: 6 additions & 6 deletions cli/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down