Skip to content

feat(publish): push to staging/<ns>/<name> and sync the served name - #16

Merged
eddie-knight merged 2 commits into
mainfrom
staging-cutover
Nov 9, 2026
Merged

eddie-knight merged 2 commits into
mainfrom
staging-cutover

Conversation

@eddie-knight

@eddie-knight eddie-knight commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

grc.store had an issue with garbage collection and preemptive validation both being brittle, so the zot registry now has staging enabled. Our previous convention didn't support that feature, so this change is necessary.

What changed

grcli publish now pushes every bundle and its signature to the staging repository staging/<namespace>/<name> and then calls POST /v1/bundles/sync for <namespace>/<name>. The hub checks the staged bundle and copies an accepted one into the served repository; nothing pushes a served repository directly, and there is no fallback. The staging repository name comes from the staging package of grc-store-protocol v0.28.1, which this PR pins.

Supporting changes:

  • The hub client timeout rises from 60 seconds to 3 minutes, above the hub's 120-second catalog sync deadline, so a slow sync ends with the hub's answer rather than a client timeout.
  • A registry 401/403 on the staging push names the staging repository and the namespace you need to own (or be the trusted CI publisher for).
  • A refused sync shows the hub's error code and says whether to run grcli publish again. A fetch_failed means the staged upload never finished or was removed (staging is cleared after about 24 hours), so the fix is to publish again.
  • --repository staging/... is refused: the flag names the served repository.
  • README, CHANGELOG, and the publish-gemara.yml workflow header describe the new flow.

Why

The hub stopped granting push on served repositories. Every upload lands in staging and only the hub's sync moves bytes into <namespace>/<name>, so a bundle is served only after the hub has checked it. grcli has to follow that or it cannot publish at all.

How to test

make ci-local
go test ./cmd ./internal/hub -run 'Publish|Push|Sync|Timeout' -v

End to end, against a hub that accepts staging pushes:

grcli login --url https://hub.preview.grc.store
grcli publish --url https://hub.preview.grc.store <catalog.yaml>

Expected: the push log shows staging/<namespace>/<name>, the sync succeeds, and grcli versions <namespace>/<name> lists the new version. With a namespace you do not own, the push fails with a 401 that names the staging repository and the namespace.

Breaking change

A grcli release from before this change pushes the served repository directly. A hub that only accepts staging pushes answers its first blob push with 401 UNAUTHORIZED, so older grcli releases cannot publish to it; upgrade grcli (in CI, set grcli-version to a release that includes this change). Conversely, this release cannot publish to a hub from before the cutover.

Pins grc-store-protocol v0.28.1 and uses its staging package to name the
upload repository. Catalog and EvaluationLog publishes push the bundle and
its signature to staging/<namespace>/<name> and then sync <namespace>/<name>;
the hub copies an accepted bundle into the served repository, and nothing
pushes a served repository directly. There is no fallback.

The hub client timeout rises from 60 seconds to 3 minutes, above the hub's
120-second catalog sync deadline, so a slow sync ends with the hub's answer
rather than a client timeout. A registry 401/403 on the staging push names
the staging repository and the namespace to own; a refused sync shows the
hub's error code and says whether to publish again.

Breaking: a grcli from before this change gets 401 UNAUTHORIZED at its first
blob push against a hub that only accepts staging pushes, and this release
cannot publish to a hub from before the cutover.

Signed-off-by: Eddie Knight <knight@linux.com>
@eddie-knight
eddie-knight requested a review from a team as a code owner November 9, 2026 16:08

@eddie-knight eddie-knight 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.

🤖 Multi-model AI review.

Verdict: needs changes, none blocking. The staging push, token scope, signing target and version pre-flight are wired correctly. The dry-run path skips the new repository check, and the one behaviour this PR adds has no test.

Do next

  1. Add a test that runs signAndNotify with --no-sign against an httptest hub and asserts the sync names <ns>/<name> while the push reference is staging/<ns>/<name>. Swapping repository and served at cmd/publish.go:221-222 passes every current test.
  2. Run the staging.Repository check on dry runs too (inline, cmd/publish.go:298). Today --dry-run --repository staging/a/b succeeds and the same real publish is refused.
  3. Give only the sync client the 3-minute timeout (internal/hub/hub.go:50). versions, verify, unpack and the publish pre-flight now wait 3 minutes on a stalled hub instead of 60 seconds.
  4. Reword the --repository help at cmd/publish.go:89: it names the served repository, and the bytes go to staging/<repository>.
  5. Split the error at cmd/publish.go:302 so solo or acme//x are not told that "staging" is not a namespace they can publish to.
  6. Assert the timeout test's own invariant, above 120 seconds (inline, internal/hub/hub_test.go:252).

Questions for the author

  • The description says GC and preemptive validation were brittle, and the protocol's staging package doc names hub ADR-0121. Is there an ADR or issue to link from the PR?
  • README, CHANGELOG and the fetch_failed hint say staging is cleared after about 24 hours. Where does that number come from? I could not find it in the hub or deploy config.

Comment thread cmd/publish.go Resolved
Comment thread cmd/publish_test.go Resolved
Comment thread internal/hub/hub_test.go Resolved
Co-authored-by: Eddie Knight <21176439+eddie-knight@users.noreply.github.com>
Signed-off-by: Eddie Knight <21176439+eddie-knight@users.noreply.github.com>
@eddie-knight
eddie-knight merged commit 113ffc9 into main Nov 9, 2026
4 checks passed
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.

2 participants