Skip to content

fix(publish-verify): look each expected tag up by name, not by scanning every tag (#985) - #987

Merged
bpalermo merged 2 commits into
mainfrom
fix/ghcr-direct-tag-lookup
Sep 27, 2026
Merged

bpalermo merged 2 commits into
mainfrom
fix/ghcr-direct-tag-lookup

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Closes #985

Problem

scripts/verify-published-artifacts.sh paged through every tag of each repository (ghcr_all_tags) and grepped for the tags it expected. A tag listing is not a snapshot. The 2026-09-27 ~11:24Z sweep overlapped a publish and reported cni-install's d526bf2 signature MISSING while the tag was there (FAIL: 1 of 260). A re-run minutes later passed 260/260.

Fix: look each expected tag up by name

Every coordinate the verifier checks has a name it can compute. So it now asks for each one directly with HEAD /v2/<repo>/manifests/<tag> (ghcr_tag_exists), accepting the OCI and Docker index and manifest media types:

answer meaning
200 present (ok)
404 MISSING, but only beside a witness (see below)
anything else (401/403/429/5xx, timeout, no connection) exit 2, inconclusive. Never reported as missing or as present
  • Image tag: <release_tag default>-<sha>. The prefix is read from bazel/img/go_multi_arch_image.bzl as of that commit, the same way chart versions are read. If it can't be read, the verifier exits 2.
  • Signatures: both layouts (sha256-<d>.sig for cosign 2, sha256-<d> for the cosign 3 bundle) are looked up by name every time, so both is still caught (ghcr_signature_layout_direct). If either lookup goes unanswered, the verifier exits 2.
  • Witness: a 404 is reported MISSING only when a tag the same repository lists (ghcr_any_tag, one n=1 page) answers 200 to the same lookup. A repository that lists nothing, or a lookup that 404s a tag the registry just listed, exits 2 instead of producing a wall of false MISSING. This is a real risk: ghcr 404s a manifest HEAD whose Accept header it doesn't match (dev → 404 with no Accept header, 200 with one). The witness replaces the old (scanned N tags) diagnostic.
  • Output: the shape consumers read is unchanged (ok, MISSING <repo>:<tag>, PASS: N artifact(s) / FAIL: M of N). Each commit also prints checked 60 expected tags directly (HEAD /v2/<repo>/manifests/<tag>; no tag listing).

Follow-on to #983's expected-red control

The control counted scanned N tags (N > 0). It now requires one witness <tag>: 200 per chart and image absence. Its offline check gained three cases, 10 → 12:

  • An unreadable registry: the verifier exits 2, so the control is inconclusive.
  • A lookup that 404s every tag: same result, exit 2 and inconclusive.
  • A perfect red with no witnesses: the control rejects it.

I also ran the live control against GHCR: OK — verifier exited 1 with 20/20 MISSING, each with a witness such as witness dev: 200.

Race proof: scripts/check-ghcr-lookup.sh (19 cases, wired into ci.yaml's shell job)

The fake registry is a curl shell function. Its listing cursor is positional. Between page 1 and page 2 a publish re-points dev, which ghcr lists first, and appends the new commit's tags. The page boundary slides past one existing tag.

  ok    OLD lookup reports a PRESENT tag missing mid-publish: walked 10 of 10 tags in 3 pages, sha256-2222…2222 never seen
  ok    NEW lookup (HEAD /v2/<repo>/manifests/<tag>) finds sha256-2222…2222 in the same registry

The OLD case asserts that the walk loses the tag. If the fake ever stops reproducing the race, that case fails rather than letting the NEW case pass vacuously.

The other cases pin:

  • the 200/404/401/429/503/no-connection answers
  • the Accept types
  • every signature layout, plus a half-answered signature lookup
  • the real verifier end to end: a complete registry passes 36/36 with exactly 60 lookups; an unsigned child gives exit 1; a 503 gives exit 2; an absent image is MISSING with its witness; an all-404 lookup gives exit 2

Real sweep (read-only, from a workstation, final code)

--recent: 14 push head(s) on origin/main since '24 hours ago', older than '2 hours ago' (4 non-head commit(s) skipped)
  checked 60 expected tags directly (HEAD /v2/<repo>/manifests/<tag>; no tag listing)   ×14
PASS: 504 artifact(s) present across 14 commit(s)

A pre-cosign-3 commit (841adf4) also passes, with its .sig tags found through the cosign 2 layout.

Trade-off to watch

Direct lookup costs about 23s per commit from this workstation, against about 13s for the old scan. Each HEAD is about 0.25s, mostly server time. The full --recent sweep took 5m23s for 14 heads. publish-verify's job has timeout-minutes: 15, so a day with many more push heads could approach it. I left the timeout alone to keep this diff focused.

Not changed

publish.yaml's sign step still uses ghcr_all_tags to find -<sha> tags. It runs inside the serialised publish, not alongside one.

Checks run

  • scripts/check-ghcr-lookup.sh 19/19, check-publish-verify-control.sh 12/12, check-signature-layout.sh, check-index-children.sh, check-push-head-selection.sh, check-shell-lint.sh
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //scripts/... and format.check on the touched scripts
  • both touched workflows parse as YAML

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 27, 2026 09:35
…ng every tag (#985)

verify-published-artifacts.sh paged through every tag of every repository
and grepped for the ones it expected. A listing is not a snapshot: the
2026-09-27 ~11:24Z sweep overlapped a publish and reported cni-install's
d526bf2 signature MISSING while it was there (FAIL: 1 of 260; a re-run
minutes later passed 260/260).

Every coordinate the verifier checks has a computable name, so it now asks
for each one directly with HEAD /v2/<repo>/manifests/<tag>
(ghcr_tag_exists, OCI + Docker index/manifest Accept types):

  200 -> present, 404 -> MISSING, anything else -> exit 2 (inconclusive).

- The image tag is `<release_tag default>-<sha>`, read from
  bazel/img/go_multi_arch_image.bzl as of the commit (like chart versions);
  unreadable -> exit 2.
- Signatures: both layouts (`sha256-<d>.sig`, `sha256-<d>`) are looked up
  by name every time, so `both` is still caught
  (ghcr_signature_layout_direct); either lookup unanswered -> exit 2.
- A 404 is reported MISSING only beside a witness: a tag the same repo lists
  (ghcr_any_tag, one page of n=1) answering 200 to the same lookup. A repo
  that lists nothing, or a lookup that 404s a listed tag (ghcr 404s a
  manifest HEAD with no matching Accept), is exit 2 rather than a wall of
  false MISSING. This replaces the old "(scanned N tags)" diagnostic, which
  the #930 expected-red control keyed on; the control now requires one
  `witness <tag>: 200` per chart and image absence, and its offline check
  covers an unreadable registry, an all-404 lookup, and an unwitnessed red.
- Per commit the verifier prints `checked N expected tags directly`.
  Output consumers are unchanged: `ok`, `MISSING <repo>:<tag>`,
  `PASS: N artifact(s)` / `FAIL: M of N`.

scripts/check-ghcr-lookup.sh (wired into ci.yaml's shell job) reproduces
the race on a fake registry: a positional listing cursor, and a publish
between page 1 and page 2 that re-points `dev` (listed first on ghcr) and
appends the new commit's tags. The OLD walk+grep must lose a present tag
(if the fake stops reproducing that, the case fails instead of the new
lookup passing vacuously); the NEW lookup must find it. It also pins
200/404/401/429/503/no-connection, the Accept types, every signature
layout, and drives the real verifier end to end (pass with exact lookup
count, unsigned child, 503 -> exit 2, witnessed absence, all-404 -> exit 2).

ghcr_all_tags stays for publish.yaml's sign step, which is serialised with
publishes and is out of scope here.

Closes #985

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the fix/ghcr-direct-tag-lookup branch from 24f265c to 94dcbdf Compare September 27, 2026 12:36
@bpalermo
bpalermo merged commit e5e8e07 into main Sep 27, 2026
24 checks passed
@bpalermo
bpalermo deleted the fix/ghcr-direct-tag-lookup branch September 27, 2026 12:47
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.

publish-verify: ghcr tag pagination can drop a tag while a publish is writing tags (transient false MISSING)

1 participant