Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
WriteSignedEntitywrites aSignedImageIndex, it callsgo-containerregistry'sremote.WriteIndex, which short-circuits if the index manifest is already present at the destination tag. It does not verify the children exist. As a result, a re-push cannot heal a partially-broken index whose top-level digest is unchanged but one of its per-arch children was previously deleted (e.g. by registry garbage collection).The fix walks the index's children first and pushes each one by digest (recursing into nested indexes) before publishing the index itself.
goremote.Write/WriteIndexon each child still short-circuits when content is already present, so the steady-state cost is unchanged; missing children are restored.Code change
pkg/oci/remote/write.go—WriteSignedEntity'sSignedImageIndexbranch now calls a newwriteIndexLeavesFirsthelper instead ofgoremote.WriteIndexdirectly:writeIndexLeavesFirstwalksIndexManifest().Manifests, pushes each leaf image by digest withgoremote.Write, recurses into nested indexes, and finally callsgoremote.WriteIndexto bind the tag.Test plan
TestWriteSignedEntity_IndexHealsMissingChild(inpkg/oci/remote/write_test.go) usesgithub.com/google/go-containerregistry/pkg/registryto spin up an in-memory OCI registry, builds a real multi-arch index, deletes one per-arch child manifest to simulate a GC pass, re-pushes, and asserts the deleted child is restored.pkg/oci/remote/tests continue to pass.Why now
This surfaced via PE-8905 — a downstream registry-side bug in Stylus where
local-syncpushes single-arch manifests andspc-synclater overwrites the tag with a multi-arch index. The orphaned single-arch manifest is reaped by Zot GC, and on the next K8s upgradecontainerd404s on its cached old digest. Centralizing the fix here in cosign avoids per-caller workarounds in Stylus, Palette, and the bundle library.Downstream propagation
After merge:
github.com/spectrocloud/cosign/v3pseudo-version inspectrocloud/bundle'sgo.mod, cutv1.3.7.github.com/spectrocloud/bundleinspectrocloud/stylus'sgo.modtov1.3.7.Made with Cursor