Skip to content

chore(image-builder-bob): Reduce retry duration #14206

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 26, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions components/image-builder-bob/pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import (
)

const (
buildkitdSocketPath = "unix:///run/buildkit/buildkitd.sock"
maxConnectionAttempts = 10
buildkitdSocketPath = "unix:///run/buildkit/buildkitd.sock"
// maxConnectionAttempts is the number of attempts to try to connect to the buildkit daemon.
// Uses exponential backoff to retry. 8 attempts is a bit over 4 minutes.
maxConnectionAttempts = 8
initialConnectionTimeout = 2 * time.Second
)

Expand Down Expand Up @@ -258,23 +260,25 @@ func connectToBuildkitd(socketPath string) (cl *client.Client, err error) {
log.WithField("attempt", i).Debug("attempting to connect to buildkitd")
cl, err = client.New(ctx, socketPath, client.WithFailFast())
if err != nil {
cancel()
if i == maxConnectionAttempts-1 {
log.WithField("attempt", i).WithError(err).Warn("cannot connect to buildkitd")
break
}

cancel()
time.Sleep(backoff)
backoff = 2 * backoff
continue
}

_, err = cl.ListWorkers(ctx)
if err != nil {
cancel()
if i == maxConnectionAttempts-1 {
log.WithField("attempt", i).WithError(err).Error("cannot connect to buildkitd")
break
}

cancel()
time.Sleep(backoff)
backoff = 2 * backoff
continue
Expand Down
4 changes: 1 addition & 3 deletions test/pkg/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,7 @@ const (
ComponentContentService ComponentType = "content-service"
// ComponentWorkspace points to a workspace
ComponentWorkspace ComponentType = "workspace"
// ComponentImageBuilder points to the image-builder
ComponentImageBuilder ComponentType = "image-builder"
Comment on lines -509 to -510
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was unused - refers to the previous image builder component

// ComponentImageBuilder points to the image-builder-mk3
// ComponentImageBuilderMK3 points to the image-builder-mk3
ComponentImageBuilderMK3 ComponentType = "image-builder-mk3"
)

Expand Down