Skip to content

fix(storage): drop imagePullSecrets from OCI auth - #1883

Open
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-1336
Open

fix(storage): drop imagePullSecrets from OCI auth#1883
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-1336

Conversation

@pujitha24

Copy link
Copy Markdown

Changes

When a TaskRun/PipelineRun's ServiceAccount has both imagePullSecrets
and mounted secrets targeting the same OCI registry, the vendored
go-containerregistry keychain consolidates both sets and returns the
first match, which is always the read-only imagePullSecrets
credential. The OCI storage backend (pkg/chains/storage/oci/legacy.go,
still the active auth path wired in pkg/chains/storage/storage.go
despite its "Deprecated" doc-comment on the Backend type) only ever
pushes signed attestations, so resolving a read-only credential makes
the push fail with an auth error even though a push-capable credential
is available in secrets.

This addresses the ServiceAccount-level case described in the issue;
the PodTemplate-level case was already fixed in a prior, separate
change.

Approach

  • Bump the vendored github.com/google/go-containerregistry
    pkg/authn/kubernetes module to the commit that merged upstream's
    IgnorePullSecrets option
    (feat(kubernetes): allow ignoring pull secrets google/go-containerregistry#2315), which
    lets the keychain skip both the ServiceAccount's imagePullSecrets
    and any explicit pull secrets.
  • Set IgnorePullSecrets: true when building the k8schain options used
    by the OCI backend, since this keychain is only ever used to push,
    never to pull.

Validation

  • go build ./... passes.
  • make test-unit passes for all packages.
  • make golangci-lint PKG=./pkg/chains/storage/oci/... reports 0 issues.
  • Added TestK8schainOptions_IgnoresImagePullSecrets, confirmed to fail
    if IgnorePullSecrets: true is removed and to pass with the fix,
    asserting the OCI backend's k8schain options are built with
    IgnorePullSecrets set.
  • Not run: no live cluster is available in this environment, so the fix
    was not reproduced end-to-end against a real registry. Correctness
    instead relies on the upstream library's own test coverage for
    IgnorePullSecrets plus the added unit test confirming this backend
    threads the option through.

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

When 'oci' is configured as the storage option for signed artifacts,
the tekton-chains-controller no longer uses the ServiceAccount's
`imagePullSecrets` to authenticate with the target OCI registry when
that ServiceAccount also has push-capable `secrets` for the same
registry.

AI assistance: this change was drafted with Claude Code.

Fixes #1336

Motivation:
When a TaskRun/PipelineRun's ServiceAccount has both
imagePullSecrets and mounted secrets targeting the same OCI
registry, the vendored go-containerregistry keychain consolidates
both sets and returns the first match, which is always the
read-only imagePullSecrets credential. The OCI storage backend
(pkg/chains/storage/oci/legacy.go, still the active auth path
wired in pkg/chains/storage/storage.go despite its "Deprecated"
doc-comment on the Backend type) only ever pushes signed
attestations, so resolving a read-only credential makes the push
fail with an auth error even though a push-capable credential is
available in secrets.

This addresses the ServiceAccount-level case described in the
issue; the PodTemplate-level case was already fixed in a prior,
separate change.

Approach:
- Bump the vendored github.com/google/go-containerregistry
  pkg/authn/kubernetes module to the commit that merged upstream's
  IgnorePullSecrets option
  (google/go-containerregistry#2315),
  which lets the keychain skip both the ServiceAccount's
  imagePullSecrets and any explicit pull secrets.
- Set IgnorePullSecrets: true when building the k8schain options
  used by the OCI backend, since this keychain is only ever used
  to push, never to pull.

Validation:
- go build ./... passes.
- make test-unit passes for all packages.
- make golangci-lint PKG=./pkg/chains/storage/oci/... reports 0
  issues.
- Added TestK8schainOptions_IgnoresImagePullSecrets, confirmed to
  fail if IgnorePullSecrets: true is removed and to pass with the
  fix, asserting the OCI backend's k8schain options are built with
  IgnorePullSecrets set.
- Not run: no live cluster is available in this environment, so
  the fix was not reproduced end-to-end against a real registry.
  Correctness instead relies on the upstream library's own test
  coverage for IgnorePullSecrets plus the added unit test
  confirming this backend threads the option through.

Report: tektoncd#1336
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign enarha after the PR has been reviewed.
You can assign the PR to them by writing /assign @enarha 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 added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chains controller uses imagePullSecrets for artifact upload, causing failure due to read-only registry access

2 participants