Skip to content

Commit 3ad27b5

Browse files
authored
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()`.
1 parent 50966c4 commit 3ad27b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cli/agent.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ func workspaceAgent() *cobra.Command {
168168
}
169169
}
170170

171-
ctx, cancelFunc := context.WithTimeout(cmd.Context(), time.Hour)
172-
defer cancelFunc()
173-
for retry.New(100*time.Millisecond, 5*time.Second).Wait(ctx) {
174-
err := client.PostWorkspaceAgentVersion(cmd.Context(), version)
171+
retryCtx, cancelRetry := context.WithTimeout(cmd.Context(), time.Hour)
172+
defer cancelRetry()
173+
for retrier := retry.New(100*time.Millisecond, 5*time.Second); retrier.Wait(retryCtx); {
174+
err := client.PostWorkspaceAgentVersion(retryCtx, version)
175175
if err != nil {
176-
logger.Warn(cmd.Context(), "post agent version: %w", slog.Error(err), slog.F("version", version))
176+
logger.Warn(retryCtx, "post agent version: %w", slog.Error(err), slog.F("version", version))
177177
continue
178178
}
179-
logger.Info(ctx, "updated agent version", slog.F("version", version))
179+
logger.Info(retryCtx, "updated agent version", slog.F("version", version))
180180
break
181181
}
182182

0 commit comments

Comments
 (0)