Skip to content

fix: wrap _ensure_buildx_builder CalledProcessError as ImageBuildError#1169

Closed
EngHabu wants to merge 1 commit into
mainfrom
claude/sentry-fix-buildx-create
Closed

fix: wrap _ensure_buildx_builder CalledProcessError as ImageBuildError#1169
EngHabu wants to merge 1 commit into
mainfrom
claude/sentry-fix-buildx-create

Conversation

@EngHabu

@EngHabu EngHabu commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

DockerImageBuilder._ensure_buildx_builder() runs docker buildx ls and docker buildx create --name flytex ... via subprocess.run(..., check=True). When those commands fail (stale flytex builder, daemon hiccup, conflicting builder, ...), the raw subprocess.CalledProcessError bubbles up to Sentry as if it were an SDK bug — but it is the user's local docker environment misbehaving and they have no actionable error.

PR #1082 already wrapped docker buildx build failures as ImageBuildError. The same treatment now extends to the _ensure_buildx_builder subprocess calls.

Fix

In src/flyte/_internal/imagebuild/docker_builder.py:

  • Wrap docker buildx ls subprocess.CalledProcessError as ImageBuildError (with docker stderr captured for context).
  • Wrap docker buildx create --name flytex ... subprocess.CalledProcessError as ImageBuildError, with a hint to run docker buildx rm flytex or override via FLYTE_DOCKER_BUILDKIT_BUILDER_NAME.

ImageBuildError is a RuntimeUserError already filtered by flyte/_sentry.py:_is_user_error, so these crashes stop polluting Sentry while the user gets an actionable message.

Closes

  • FLYTE-SDK-4RCalledProcessError: Command '['docker', 'buildx', 'create', ...]' returned non-zero exit status 1.

fixes FLYTE-SDK-4R

Tests

  • Added test_ensure_buildx_builder_wraps_create_called_process_error (create fails → ImageBuildError).
  • Added test_ensure_buildx_builder_wraps_ls_called_process_error (ls fails → ImageBuildError).

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
@EngHabu EngHabu added the sentry-fix Fix for an issue surfaced by Sentry label Jun 5, 2026
@EngHabu

EngHabu commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #1167, which addresses the same Sentry issue (FLYTE-SDK-4R) and is a superset of this change: it wraps both docker buildx ls and docker buildx create failures as ImageBuildError, and additionally reuses an existing builder when create fails with "already exists" (handling concurrent-build races). #1167 has been rebased onto latest main with green CI.

@EngHabu EngHabu closed this Jun 6, 2026
@EngHabu EngHabu deleted the claude/sentry-fix-buildx-create branch June 6, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sentry-fix Fix for an issue surfaced by Sentry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant