Skip to content

Commit

Permalink
Merge pull request #35 from depot/retry
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie authored May 24, 2022
2 parents 7fd2c99 + af3f0b3 commit 09603c9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (b *Builder) Acquire(l progress.Logger) (string, error) {
var err error
var accessToken string

err = progress.Wrap("[depot] launching "+b.Platform+" builder", l, func(sub progress.SubLogger) error {
acquireFn := func(sub progress.SubLogger) error {
resp, err = b.depot.GetBuilder(b.BuildID, b.Platform)
if err != nil {
return err
Expand All @@ -58,15 +58,21 @@ func (b *Builder) Acquire(l progress.Logger) (string, error) {
time.Sleep(time.Duration(resp.PollSeconds) * time.Second)
resp, err = b.depot.GetBuilder(b.BuildID, b.Platform)
count += 1
if count > 60 {
if count > 30 {
return errors.New("Unable to acquire builder connection")
}
}

return nil
})
}

// Try to acquire builder twice
err = progress.Wrap("[depot] launching "+b.Platform+" builder", l, acquireFn)
if err != nil {
return "", err
err = progress.Wrap("[depot] launching "+b.Platform+" builder", l, acquireFn)
if err != nil {
return "", err
}
}

err = progress.Wrap("[depot] connecting to "+b.Platform+" builder", l, func(sub progress.SubLogger) error {
Expand Down

0 comments on commit 09603c9

Please sign in to comment.