Skip to content

Commit

Permalink
Merge pull request #1923 from leathekd/dont-timeout-build
Browse files Browse the repository at this point in the history
only use the ctx w/ timeout where necessary
  • Loading branch information
moskyb authored Jan 19, 2023
2 parents ec8675e + a5c6671 commit 3178702
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions agent/agent_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (a *AgentWorker) AcquireAndRunJob(ctx context.Context, jobId string) error
// always hit the max of 1s, then another 8s is added to that. This is still comfortably within
// the timeout of 270s, and the bound seems tight enough so that the agent is not wasting time
// waiting for a retry that will never happen.
ctx, cancel := context.WithTimeout(ctx, 270*time.Second)
timeoutCtx, cancel := context.WithTimeout(ctx, 270*time.Second)
defer cancel()

// Acquire the job using the ID we were provided. We'll retry as best we can on non 422 error.
Expand All @@ -543,7 +543,7 @@ func (a *AgentWorker) AcquireAndRunJob(ctx context.Context, jobId string) error
roko.WithMaxAttempts(10),
roko.WithStrategy(roko.Constant(3*time.Second)),
roko.WithSleepFunc(a.retrySleepFunc),
).DoWithContext(ctx, func(r *roko.Retrier) error {
).DoWithContext(timeoutCtx, func(r *roko.Retrier) error {
// If this agent has been asked to stop, don't even bother
// doing any retry checks and just bail.
if a.stopping {
Expand All @@ -554,7 +554,7 @@ func (a *AgentWorker) AcquireAndRunJob(ctx context.Context, jobId string) error
var response *api.Response

acquiredJob, response, err = a.apiClient.AcquireJob(
ctx, jobId,
timeoutCtx, jobId,
api.Header{Name: "X-Buildkite-Lock-Acquire-Job", Value: "1"},
api.Header{Name: "X-Buildkite-Backoff-Sequence", Value: fmt.Sprintf("%d", r.AttemptCount())},
)
Expand Down

0 comments on commit 3178702

Please sign in to comment.