Skip to content

Raise DockerBuildError on Docker build failures#258

Open
kailun-qin wants to merge 1 commit into
masterfrom
kailun-qin/exit-on-build-error
Open

Raise DockerBuildError on Docker build failures#258
kailun-qin wants to merge 1 commit into
masterfrom
kailun-qin/exit-on-build-error

Conversation

@kailun-qin

@kailun-qin kailun-qin commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Description of the changes

Previously, build_docker_image() ignored the 'error' key in the Docker API stream, relying solely on get_docker_image() to catch build failures. This caused the script to incorrectly report success even if a build instruction failed, when a stale Graminized image existed.

This commit adds an explicit check for the 'error' key and introduces a DockerBuildError exception. All callers are updated to catch this exception and exit, ensuring build failures are correctly reported.

How to test this PR?

Manual testing: run gsc build w/ the python:bullseye example from our doc.

Before this fix:

$ docker images
REPOSITORY   TAG                 IMAGE ID       CREATED        SIZE
gsc-python   bullseye-unsigned   e647502b2b77   3 hours ago    1.04GB

$ ./gsc build --insecure-args python:bullseye test/generic.manifest
...
Err:5 http://deb.debian.org/debian bullseye-backports Release
  404  Not Found [IP: 10.224.224.80 911]
...
Reading package lists...

E: The repository 'http://deb.debian.org/debian bullseye-backports Release' does not have a Release file.

Successfully built an unsigned graminized Docker image `gsc-python:bullseye-unsigned` from original application image `python:bullseye`.

After this fix:

E: The repository 'http://deb.debian.org/debian bullseye-backports Release' does not have a Release file.

Docker build failed: The command '/bin/sh -c echo 'deb http://deb.debian.org/debian bullseye-backports main' > /etc/apt/sources.list.d/backports.list     && env DEBIAN_FRONTEND=noninteractive apt-get update     && env DEBIAN_FRONTEND=noninteractive apt-get install -y -t bullseye-backports linux-libc-dev' returned a non-zero code: 100

This change is Reviewable

@kailun-qin kailun-qin force-pushed the kailun-qin/exit-on-build-error branch from d2ba7a2 to 0ac2bc4 Compare April 13, 2026 12:11
@kailun-qin kailun-qin changed the title Ensure immediate exit on Docker build errors Raise DockerBuildError on Docker build failures Apr 13, 2026
Previously, `build_docker_image()` ignored the 'error' key in the Docker
API stream, relying solely on `get_docker_image()` to catch build
failures. This caused the script to incorrectly report success even if a
build instruction failed, when a stale Graminized image existed.

This commit adds an explicit check for the 'error' key and introduces a
`DockerBuildError` exception. All callers are updated to catch this
exception and exit, ensuring build failures are correctly reported.

Signed-off-by: Kailun Qin <kailun.qin@intel.com>
@kailun-qin kailun-qin force-pushed the kailun-qin/exit-on-build-error branch from 0ac2bc4 to 08cc08f Compare April 13, 2026 12:41

@kailun-qin kailun-qin left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please note that this works fine under a clean setup. Not sure if we consider this as a false positive -- I'm raising it here anyway.

@kailun-qin made 1 comment.
Reviewable status: 0 of 1 files reviewed, all discussions resolved, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel).

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