Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix exit code when manifest merge failed #2424

Merged

Conversation

jaihwan104
Copy link
Contributor

When the immutable policy is applied to tags and the manifest push fails, the exit code is calculated as 0. This issue occurs when using the remote driver.

We are building images in GitLab CI. Even though the image was not pushed properly, the exitCode is calculated as 0, so the job is not stopping properly.

fix exit code when manifest merge failed as follow:

before:

bash-5.2# docker buildx build --push --platform linux/amd64,linux/arm64 -f Dockerfile -t myregistry.com/hello/world:test .
...
 => => pushing layers                                                                                                                                                         0.8s
 => => pushing manifest for myregistry.com/hello/world                                                                                                                  0.9s
 => [auth] hello/world:pull,push token for myregistry.com                                                                                               0.0s
 => [auth] hello/world:pull,push token for myregistry.com                                                                                                  0.0s
 => ERROR merging manifest list myregistry.com/hello/world:test                                                                                                         0.3s
------
 > merging manifest list myregistry.com/hello/world:test:
------

bash-5.2# echo $?
0

after:

bash-5.2# docker buildx build --push --platform linux/amd64,linux/arm64 -f Dockerfile -t myregistry.com/hello/world:test .
...
 => => pushing layers                                                                                                                                                         1.0s
 => => pushing manifest for myregistry.com/hello/world                                                                                                                  1.2s
 => [auth] hello/world:pull,push token for myregistry.com                                                                                                               0.0s
 => [auth] hello/world:pull,push token for myregistry.com                                                                                                               0.0s
 => ERROR merging manifest list myregistry.com/hello/world:test                                                                                                         1.0s
------
 > merging manifest list myregistry.com/hello/world:test:
------
ERROR: failed commit on ref "index-sha256:949e4827d78c5cb6e2e6445804681208db7ed53dfb6417081b342f7faceceb37": unexpected status from PUT request to https://myregistry.com/v2/hello/world/manifests/test: 412 Precondition Failed

bash-5.2# echo $?
1

@jaihwan104 jaihwan104 force-pushed the exit-1-when-manifest-merge-failed branch 2 times, most recently from 889882e to e0a76d3 Compare April 22, 2024 14:51
Signed-off-by: jaihwan104 <42341126+jaihwan104@users.noreply.github.com>
@jaihwan104 jaihwan104 force-pushed the exit-1-when-manifest-merge-failed branch from e0a76d3 to f282351 Compare April 22, 2024 14:56
@tonistiigi tonistiigi merged commit 771e66b into docker:master Apr 24, 2024
85 checks passed
@jaihwan104
Copy link
Contributor Author

@tonistiigi Thank you for the review. I'd like to apply the official version to the production. Could you please add it to milestone v0.14.1?

@crazy-max crazy-max added this to the v0.15.0 milestone May 16, 2024
@thompson-shaun thompson-shaun added the kind/bug Something isn't working label May 16, 2024
@thompson-shaun thompson-shaun modified the milestones: v0.15.0, v0.14.1 May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants