Repository navigation
fix(pre_start): name the hook when its container cannot start - #14520
Merged
Merged
Conversation
A pre_start hook container that fails to start (an executable missing from the image of the hook, a bad mount, ...) was reported with the bare error of the engine. It names neither the hook nor its image, and it surfaces on the row of the service container, so it reads as the service failing to start. Wrap it with the service, the index of the hook and its image, like the other pre_start errors: service "app" pre_start[0] (image hello-world): failed to start the hook container: <engine error>. The wrapped error is unchanged for errors.Is and errors.As. Refs docker#14513 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Lower-confidence findings (not posted inline)
- [low] pkg/compose/pre_start.go:272 — hookImageSuffix returns empty string when hook inherits the service image (Image == ""), so the error message omits the image name in the most common case; consider threading the resolved image name through to the caller (confidence: not scored — low severity, not verified)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does, in one sentence
Names the
pre_starthook, and its image, in the error reported when the hook container cannot start.Context
A
pre_starthook is the service container with only the attributes it declares replaced, so it inherits the service'sentrypointeven when the hook sets anotherimage(#14513). When that executable does not exist in the image of the hook, the engine refuses to start the hook container, andupfails with the bare engine error (exec: "/bin/busybox": stat /bin/busybox: no such file or directory). It names neither the hook nor its image, and it surfaces on the row of the service container (Container app-1 Starting→Error), so it reads as the service failing to start and sends the user looking in the wrong place.What the PR brings
The error now reads
service "app" pre_start[0] (image hello-world): failed to start the hook container: <engine error>, in the same form as the otherpre_starterrors, both on the progress row and in the final error. The engine error is wrapped, soerrors.Isanderrors.Asstill see it.The inheritance itself is unchanged: it follows the spec, and
entrypoint: []orentrypoint: nullon the hook opts out of it.Addresses #14513 (the error message part; the inheritance is how the spec defines
pre_start).🤖 Generated with Claude Code