Fix duplicate .att/.sig OCI layers for same digest type hints#1601
Conversation
84b9ba9 to
0151950
Compare
|
/approve |
|
/kind bug |
|
/cc @jkhelil |
| continue | ||
| } | ||
| if seen[dgst.DigestStr()] { | ||
| continue |
There was a problem hiding this comment.
NIT - Adding a log line for eg. logger.Debugf("Skipping duplicate digest %s", dgst.DigestStr()) would help people understand why an image wasn't processed.
There was a problem hiding this comment.
Thanks for the suggestion, addressed.
| continue | ||
| } | ||
| if seen[dgst.DigestStr()] { | ||
| continue |
0151950 to
7d970c4
Compare
|
/lgtm |
|
@infernus01: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
| logger.Errorf("error getting digest: %v", err) | ||
| continue | ||
| } | ||
| if seen[dgst.DigestStr()] { |
There was a problem hiding this comment.
@ab-ghosh dgst.DigestStr() returns only sha256:xxx, stripping the repository name entirely. This means two legitimately different images that happen to produce the same content digest (e.g., a mirrored image gcr.io/my/img@sha256:abc and quay.io/my/img@sha256:abc) will be silently deduplicated, dropping one of them from the signing set. so could you consider dgst.Name() that uses the full repo@SHA256:XYZ. Also please include test case addressing this.
There was a problem hiding this comment.
Yeah, that's right, thanks for the suggestion. I have updated it to use dgst.Name() and also added a test case to cover this scenario.
7d970c4 to
6a97a81
Compare
|
@ab-ghosh - with #1578 merged now, could we check the feasibility to dedup any image url /digest that could be duplicated with a TR that has results: results:
Please consider this task definition as a sample - https://gist.github.com/anithapriyanatarajan/1650aeb3ebdbcea05d4a9baef649507c#file-gistfile1-txt-L123-L190 |
d0d5463 to
edf93b1
Compare
|
Added dedup for the ARTIFACT_OUTPUTS. Also added unit test which covers the exact scenario from your sample task (same image in both IMAGE_URL/IMAGE_DIGEST and build-image-ARTIFACT_OUTPUTS) |
When a Task declares the same OCI image through multiple type-hint
formats (IMAGE_URL/IMAGE_DIGEST, IMAGES, and *ARTIFACT_OUTPUTS),
Chains produces duplicate layers in cosign .att/.sig manifests.
This adds dedup at two levels:
1. Extraction: track seen digests in ExtractOCIImagesFromResults to
avoid returning the same digest from different type-hint formats
2. Storage: check existing layers in AttestationStorer and SimpleStorer
before appending, preventing duplicates from independent signable
types (TaskRunArtifact + OCIArtifact) storing to the same tag
Also adds debug logging when existing layer checks fail instead of
silently swallowing errors.
Fixes tektoncd#1596
edf93b1 to
b0a0331
Compare
|
/lgtm |
|
/cc @jkhelil |
|
/approve Approving this PR based after feature testing on a kind cluster following steps here - https://gist.github.com/anithapriyanatarajan/81fc8c92ceccf760ce74f40c7b30a2f9 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anithapriyanatarajan, infernus01 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
When a Task declares the same OCI image through multiple type-hint formats, produces duplicate layers in the
.attand/or.sigmanifests.This fixes the issue at two levels:
seenmap inExtractOCIImagesFromResultsto skip already-extracted digests across all type-hint parsing loops.AttestationStorer.StoreandSimpleStorer.Store, check if a layer with the same content digest already exists. This handles the case where independent signable types (TaskRunArtifactandOCIArtifact) both store to the same.att/.sigtag.Fixes #1596
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
Release Notes