Skip to content

Commit

Permalink
Merge pull request #2069 from buildkite/artifacts-roko-exponential-su…
Browse files Browse the repository at this point in the history
…bsecond

ArtifactBatchCreator & ArtifactUploader: use roko.ExponentialSubsecond
  • Loading branch information
moskyb authored May 4, 2023
2 parents 8563597 + b09d2e2 commit 7547017
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions agent/artifact_batch_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ func (a *ArtifactBatchCreator) Create(ctx context.Context) ([]*api.Artifact, err

// Retry the batch upload a couple of times
err = roko.NewRetrier(
// TODO: e.g. roko.ExponentialSubsecond(500*time.Millisecond) WithMaxAttempts(10)
// see: https://github.com/buildkite/roko/pull/8
// Meanwhile, 8 roko.Exponential(2sec) attempts is 1,2,4,8,16,32,64 seconds delay (~2 mins)
roko.WithMaxAttempts(8),
roko.WithStrategy(roko.Exponential(2*time.Second, 0)),
roko.WithMaxAttempts(10),
roko.WithStrategy(roko.ExponentialSubsecond(500*time.Millisecond)),
).DoWithContext(ctx, func(r *roko.Retrier) error {

ctxTimeout := ctx
Expand Down
7 changes: 2 additions & 5 deletions agent/artifact_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,8 @@ func (a *ArtifactUploader) upload(ctx context.Context, artifacts []*api.Artifact

// Update the states of the artifacts in bulk.
err := roko.NewRetrier(
// TODO: e.g. roko.ExponentialSubsecond(500*time.Millisecond) WithMaxAttempts(10)
// see: https://github.com/buildkite/roko/pull/8
// Meanwhile, 8 roko.Exponential(2sec) attempts is 1,2,4,8,16,32,64 seconds delay (~2 mins)
roko.WithMaxAttempts(8),
roko.WithStrategy(roko.Exponential(2*time.Second, 0)),
roko.WithMaxAttempts(10),
roko.WithStrategy(roko.ExponentialSubsecond(500*time.Millisecond)),
).DoWithContext(ctx, func(r *roko.Retrier) error {
ctxShort, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
Expand Down

0 comments on commit 7547017

Please sign in to comment.