Repository navigation
Tag builder latest by the digest of the full manifest list - #1450
Conversation
|
|
ea92eba to
755bb1d
Compare
755bb1d to
5209fbe
Compare
| EXPECTED_TARGETS=$(grep -c '^\[\[targets\]\]' "${{ matrix.builders.path }}/builder.toml" || true) | ||
| # pack publishes a manifest list only for more than one target, otherwise a plain image | ||
| if [ "${EXPECTED_TARGETS}" -le 1 ]; then | ||
| EXPECTED_TARGETS=0 |
There was a problem hiding this comment.
I think this one should be 1, as even on single arch, we always have one target, the amd64. WDYT? It works, because the manifest.json will return 0, but is a little bit confusing. WDYT?
There was a problem hiding this comment.
Right now TARGETS counts the entries of the manifest list, not platforms. A single-arch builder is published as a plain image without .manifests, so it’s 0 there, and that’s why I set EXPECTED_TARGETS to 0. I can switch both sides to count platforms instead: a plain image counts as 1 (if .manifests then (.manifests | length) else 1 end), and a builder.toml without targets expects 1. Then it reads naturally and still catches the race (a single-arch image gives 1 where 2 are expected). Want me to change it?
There was a problem hiding this comment.
Thank your for describing me the code.
Sorry, What do you mean
(a single-arch image gives 1 where 2 are expected)
Also, what do you think, what is your opinion about which one is more readable?
I like the platform idea, as at the end of the day is a docker issue, not buildpacks one.
There was a problem hiding this comment.
The targets also means in which platform the builder will run, so even in case of the target, to me, this one seems to be 1 too
There was a problem hiding this comment.
During the race, the version tag points for a moment to the image of a single platform, like the arm64 one that ended up in latest. Counting platforms, that image gives 1 while builder.toml expects 2, so the step waits and reads again instead of tagging it. (a single-arch image gives 1 where 2 are expected)
Counting platforms reads better to me too: TARGETS and EXPECTED_TARGETS mean the same thing, so there’s no “0 means single-arch” trick.I’ll switch it to platforms and push the change.
There was a problem hiding this comment.
Can please also rename the variable name to be platforms instead of targets?
There was a problem hiding this comment.
Can you please also remove the comments?
5209fbe to
68a0ae8
Compare
pack pushes an image per target under the version tag before it pushes the manifest list there, and the registry can still return one of those right after the push. On builder-noble-java-tiny 0.0.200, `crane tag <version> latest` copied the linux/arm64 image to `latest`, so amd64 builds failed with "exec format error" (paketo-buildpacks/builder-noble-java-tiny#344). Read the version tag until it lists every target of builder.toml (fail after a minute), then tag latest by the digest of exactly that manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68a0ae8 to
20034e0
Compare
Summary
Fixes paketo-buildpacks/builder-noble-java-tiny#344.
pack builder create --publishpushes an image per target under the version tag before it pushes the manifest list there (pkg/client/create_builder.go), and the registry can still return one of those right after the push. On builder-noble-java-tiny 0.0.200 (run 39973018505),crane tag <version> latestread:0.0.200about 2 s after the manifest list was pushed and copied its linux/arm64 child (sha256:771c7c33…) tolatest. Every amd64 build on the default Spring Boot / pack builder then failed withexec /cnb/lifecycle/creator: exec format error. 0.0.199 used the same runner image and tool versions and tagged the index correctly, so this is a race, not a tooling change.Change
In
builder/.github/workflows/push-image.yml, read the version tag withcrane manifestuntil it lists every[[targets]]ofbuilder.toml, then taglatestby the digest of exactly that manifest. Sincecrane manifestprints the raw bytes,sha256sumof its output is the digest, and the tag is never read twice. A builder with at most one target is tagged right away. If the version tag still doesn't list every target after 12 reads, 5 s apart, the job fails, and the existing failure job files an issue.Alternatives considered:
pack builder create --tag latest: pack applies additional tags only to the per-target images, not to the manifest list, solatestwould always end up single-platform.--append-image-name-suffix: fixes the race at the source, but adds two-linux-<arch>tags to Docker Hub per release.Testing
actionlint(with shellcheck) passes.cranethat returns the real 0.0.200 manifests:latestgets the index digestsha256:7c62dd7e…;builder.toml: tagged right away.🤖 Generated with Claude Code