Refactor sigstore attachment config handling - #2974
Closed
Squid-Bomb wants to merge 1 commit into
Closed
Conversation
will fix openshift/oc-mirror#1478 Signed-off-by: Michael <58675276+Squid-Bomb@users.noreply.github.com>
|
This repository has been migrated to https://github.com/containers/container-libs. Please open your PR there. |
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
Bump
github.com/containers/image/v5to pick up the sigstore attachmentconfig fix in containers/image@7f71ddf,
which resolves
manifest invaliderrors when mirroring cosign signatureOCI artifacts to self-hosted Quay registries.
Closes #1478
Problem
When mirroring OCP release images to a self-hosted Quay registry with
--remove-signatures=false, cosign signature manifests (sha256-*.sig)fail to push with HTTP 400
manifest invalidfor any component imagewhose sig manifest contains repeated identical layer digests.
This affects OCP component images that have been signed multiple times
(e.g. images shared across multiple OCP releases), which accumulate one
identical cosign layer per signing operation. A typical affected manifest
has 8 layers all with the same digest.
The error surfaces as:
[ERROR]: [Worker] error mirroring image quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:
error: writing signatures: uploading manifest sha256-.sig to /platform/openshift/release: manifest invalid
Root Cause
In
putSignaturesToSigstoreAttachments(docker/docker_image_dest.go incontainers/image), when a sig manifest has duplicate layer digests, all
but the first are detected as duplicates and skipped. The function then
constructs a new 1-layer manifest with a freshly serialized OCI image
config containing:
{"rootfs": {"type": "layers", "diff_ids": ["sha256:<cosign-payload-digest>"]}} diff_ids is an OCI image concept for uncompressed tar layer digests. The value written here is the digest of a 334-byte cosign JSON payload, not a tar archive. Quay validates diff_ids entries against the OCI image spec and rejects the manifest. Manually pushing the verbatim source manifest (which uses a correct empty {} config, the cosign standard) succeeds with HTTP 201, confirming the issue is in how containers/image constructs the config — not in Quay or the manifest content itself. Fix The upstream fix in containers/image@7f71ddf removes the intermediate imgspecv1.Image struct entirely. For new sig manifests it uses []byte("{}") directly (the correct cosign empty config). For existing manifests it fetches the config blob verbatim without unmarshalling/remarshalling, preserving whatever the registry already has. The DiffIDs append and final json.Marshal are removed. Testing Mirrored OCP stable-4.18 (4.18.33–4.18.48), stable-4.19, and stable-4.20 channels to a self-hosted Quay 3.16 instance Confirmed zero manifest invalid errors across all sig manifest pushes Spoke clusters validated image signatures successfully post-sync Reproduced the failure on the previous vendor version and confirmed it is resolved with this bump