Skip to content

Fix duplicate .att/.sig OCI layers for same digest type hints#1601

Open
ab-ghosh wants to merge 1 commit intotektoncd:mainfrom
ab-ghosh:fix-duplicate-oci-layers-1596
Open

Fix duplicate .att/.sig OCI layers for same digest type hints#1601
ab-ghosh wants to merge 1 commit intotektoncd:mainfrom
ab-ghosh:fix-duplicate-oci-layers-1596

Conversation

@ab-ghosh
Copy link
Copy Markdown
Member

Changes

When a Task declares the same OCI image through multiple type-hint formats, produces duplicate layers in the .att and/or .sig manifests.

This fixes the issue at two levels:

  1. Extraction-level dedup — Added a seen map in ExtractOCIImagesFromResults to skip already-extracted digests across all type-hint parsing loops.
  2. Storage-level dedup — Before appending a new layer in AttestationStorer.Store and SimpleStorer.Store, check if a layer with the same content digest already exists. This handles the case where independent signable types (TaskRunArtifact and OCIArtifact) both store to the same .att/.sig tag.

Fixes #1596

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 28, 2026
@ab-ghosh ab-ghosh force-pushed the fix-duplicate-oci-layers-1596 branch from 84b9ba9 to 0151950 Compare March 28, 2026 18:58
@anithapriyanatarajan
Copy link
Copy Markdown
Contributor

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 1, 2026
@anithapriyanatarajan anithapriyanatarajan removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 1, 2026
@anithapriyanatarajan
Copy link
Copy Markdown
Contributor

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 1, 2026
@ab-ghosh
Copy link
Copy Markdown
Member Author

ab-ghosh commented Apr 1, 2026

/cc @jkhelil

Copy link
Copy Markdown
Member

@infernus01 infernus01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small NIT.

continue
}
if seen[dgst.DigestStr()] {
continue
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, addressed.

continue
}
if seen[dgst.DigestStr()] {
continue
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same NIT here.

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2026
@ab-ghosh ab-ghosh force-pushed the fix-duplicate-oci-layers-1596 branch from 0151950 to 7d970c4 Compare April 2, 2026 08:27
@infernus01
Copy link
Copy Markdown
Member

/lgtm

@tekton-robot
Copy link
Copy Markdown

@infernus01: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

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()] {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tekton-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: infernus01
To complete the pull request process, please assign anithapriyanatarajan after the PR has been reviewed.
You can assign the PR to them by writing /assign @anithapriyanatarajan in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2026
  When a Task declares the same OCI image through multiple type-hint
  formats (IMAGE_URL/IMAGE_DIGEST and IMAGES), 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
@ab-ghosh ab-ghosh force-pushed the fix-duplicate-oci-layers-1596 branch from 7d970c4 to 6a97a81 Compare April 13, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate .att / .sig layers when multiple type hints resolve to the same digest

4 participants