Skip to content

Commit fc916b7

Browse files
WVerlaekroboquat
authored andcommitted
chore(image-builder-mk3): Reduce retry duration
1 parent d7572fd commit fc916b7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: components/image-builder-bob/pkg/builder/builder.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import (
2424
)
2525

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

@@ -258,23 +260,25 @@ func connectToBuildkitd(socketPath string) (cl *client.Client, err error) {
258260
log.WithField("attempt", i).Debug("attempting to connect to buildkitd")
259261
cl, err = client.New(ctx, socketPath, client.WithFailFast())
260262
if err != nil {
263+
cancel()
261264
if i == maxConnectionAttempts-1 {
262265
log.WithField("attempt", i).WithError(err).Warn("cannot connect to buildkitd")
266+
break
263267
}
264268

265-
cancel()
266269
time.Sleep(backoff)
267270
backoff = 2 * backoff
268271
continue
269272
}
270273

271274
_, err = cl.ListWorkers(ctx)
272275
if err != nil {
276+
cancel()
273277
if i == maxConnectionAttempts-1 {
274278
log.WithField("attempt", i).WithError(err).Error("cannot connect to buildkitd")
279+
break
275280
}
276281

277-
cancel()
278282
time.Sleep(backoff)
279283
backoff = 2 * backoff
280284
continue

Diff for: test/pkg/integration/integration.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ const (
506506
ComponentContentService ComponentType = "content-service"
507507
// ComponentWorkspace points to a workspace
508508
ComponentWorkspace ComponentType = "workspace"
509-
// ComponentImageBuilder points to the image-builder
510-
ComponentImageBuilder ComponentType = "image-builder"
511-
// ComponentImageBuilder points to the image-builder-mk3
509+
// ComponentImageBuilderMK3 points to the image-builder-mk3
512510
ComponentImageBuilderMK3 ComponentType = "image-builder-mk3"
513511
)
514512

0 commit comments

Comments
 (0)