Skip to content

fix(image): recognise buildx's real "builder exists" error when creating flytex concurrently - #1631

Open
ittus wants to merge 1 commit into
flyteorg:mainfrom
ittus:fix/buildx-builder-exists-race
Open

ittus wants to merge 1 commit into
flyteorg:mainfrom
ittus:fix/buildx-builder-exists-race

Conversation

@ittus

@ittus ittus commented Sep 30, 2026 •

Copy link
Copy Markdown

Why

flyte deploy builds missing images concurrently. On a host with no flytex builder yet (a fresh CI runner, a new laptop), every build runs docker buildx ls, sees nothing, and runs docker buildx create --name flytex. The second create fails and the whole deploy aborts:

ImageBuildError: Failed to create docker buildx builder 'flytex':
ERROR: existing instance for "flytex" but no append mode, specify the node name to
make changes for existing instances. Try removing it with `docker buildx rm flytex`, ...

#1167 added a guard for this race, but it matches "already exists" in stderr. buildx never prints that for a duplicate create --name. The message comes from builder/builder.go#L485:

errors.Errorf("existing instance for %q but no append mode, specify the node name to make changes for existing instances", name)

already exists is only printed for a duplicate node name inside a builder or a name that clashes with a Docker context. The test added in #1167 fakes the stderr existing instance for "flytex" already exists, which buildx never prints, so the test passes without exercising the real message.

What

  • _ensure_buildx_builder reuses the builder when create fails with but no append mode as well as already exists.
  • The match is but no append mode rather than the existing instance for prefix. builder.go#L488 also starts with that prefix (existing instance for %q but has mismatched driver %q), and that builder isn't one we should reuse, so it still raises ImageBuildError.
  • Nothing changes when create succeeds or fails for another reason.

Test

  • Unit test

@ittus
ittus force-pushed the fix/buildx-builder-exists-race branch from ac33849 to 2f75cc3 Compare September 30, 2026 13:33
@ittus
ittus marked this pull request as ready for review September 30, 2026 13:38
…ing flytex concurrently

`docker buildx create --name flytex` reports a taken name as
`existing instance for "flytex" but no append mode`, not "already exists",
so the concurrent-create guard from flyteorg#1167 never fired and parallel image
builds on a host without the builder aborted the deploy.

Match "but no append mode" as well as "already exists". An existing builder
with a mismatched driver still raises.

Signed-off-by: Thang Vu <vuminhthang.cm@gmail.com>
@ittus
ittus force-pushed the fix/buildx-builder-exists-race branch from 2f75cc3 to ab7962d Compare September 30, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant