Skip to content

fix: a digest-pinned clone source gets a valid, content-named local snapshot - #118

Merged
CMGS merged 3 commits into
mainfrom
clone-by-digest
Sep 28, 2026
Merged

CMGS merged 3 commits into
mainfrom
clone-by-digest

Conversation

@CMGS

@CMGS CMGS commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Bug

A CocoonSet clone source pinned by digest, repo@sha256:<hex>, went through ociutil.ParseRef, which split at the first colon: repo became repo@sha256 and the tag the bare hex. The local snapshot name then contained @, outside cocoon's snapshot-name grammar ^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,62}$, so cocoon snapshot import rejected it. Digest-pinned clone sources did not work.

Fix

The split now has one owner: cocoonstack/cocoon-common#37 teaches ParseRef the repo@digest form (and IsRelativeRef its grammar). This PR pins cocoon-common to #37's branch commit; the clone path, the GC keep-set and run mode's resolveRunImage all go through ParseRef unchanged. localSnapshotName(repo, "sha256:<hex>") yields a valid name bound to the content (hash-suffixed to 63 characters), so an existing local copy is always the same content, and the registry fetch goes by digest.

The first commit carried a local splitter; the second drops it in favour of cocoon-common, so the net diff is the pin plus a test.

Companion

cocoonstack/cocoon-webhook#28: admission rejected every digest clone source before it reached vk-cocoon; it bumps to the same cocoon-common commit.

Order

cocoon-common#37 → re-pin this PR and webhook#28 to the merge commit or tag → merge both. vk-cocoon#117 pins cocoon-common#36; whichever of #117/#118 lands second takes one re-pin.

Evidence

  • TestLocalSnapshotNameForDigestRefs: ParseRef splits the digest ref correctly; the derived names match cocoon's grammar, differ per digest, and keep the repo prefix.
  • Gates (GOWORK=off): make lint 0 issues on linux and darwin, make fmt-check clean, asl ./... clean on both GOOS, go test -race ./... green.
  • Not yet run on hardware. Hot path: one extra strings.Cut per parse.

…napshot

A clone ref written as repo@sha256:<hex> was split at its first colon, which
turned the repo into repo@sha256 and the local snapshot name into a string
with an @, outside cocoon's snapshot-name grammar, so the import could not
land. snapshotSource splits on @ first, pulls by digest, and names the local
copy after the digest, so an existing local copy is by construction the same
content and is reused without a registry round trip. The GC keep-set uses the
same derivation so it keeps what the clone path created.
cocoon-common#37 teaches ParseRef the repo@digest form, and cocoon-webhook
needs the same grammar, so the split has one owner. Drops the local
snapshotSource and pins cocoon-common to #37's branch commit; the clone path
and the GC keep-set are back to ParseRef plus localSnapshotName, which yields a
valid, digest-bound local name. Run mode's resolveRunImage now splits digest
refs correctly too.
@CMGS
CMGS merged commit 731b09a into main Sep 28, 2026
4 checks passed
@CMGS
CMGS deleted the clone-by-digest branch September 28, 2026 17:40
CMGS added a commit that referenced this pull request Sep 29, 2026
The reclaimer treated every unused vk- snapshot as a VM's hibernate copy and
verified it against <name>:hibernate in the registry. A clone-source copy of a
non-default tag or a digest carries a colon in its local name, so that lookup
built an invalid reference, the error was not errStaleLocalSnapshot, and the
copy was kept forever with no log line. #118 made every digest clone source
land on this path; the kit's N28 run left two 1 GiB digest copies on the node.

VM names never contain a colon, so a colon in the name marks a pulled
clone-source copy: re-pullable, owned by no VM, and safe to drop once no pod on
the node clones from it. Verify errors that are not staleness now log at Warn
instead of vanishing.
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.

1 participant