Skip to content

fix(common): apply registry override to image args - #3885

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

fix(common): apply registry override to image args#3885
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-3270

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Changes

Fixes TEKTON_REGISTRY_OVERRIDE not being applied to images passed as container CLI args (e.g. -workingdirinit-image, -el-image, -shell-image-win).

TEKTON_REGISTRY_OVERRIDE is documented as a way to rewrite the registry for every image the operator deploys, but only container.Image, Task step images, and StepAction images had a fallback that applies it when no per-image env var is set. Images passed as container CLI args were skipped by that fallback, so in an air-gapped install those container args still pointed at the public upstream registries (gcr.io, mcr.microsoft.com) even with TEKTON_REGISTRY_OVERRIDE set, unless the user also set every documented per-image env var individually.

replaceContainersArgsImage (pkg/reconciler/common/transformers.go) only rewrote an arg's image when a matching per-image env var existed. This adds the same registry-override fallback already used by replaceContainerImages/replaceStepsImages/replaceStepActionImages: when no per-image override matches an arg whose flag name looks like an image flag (contains _image once normalized, covering both -foo-image and -foo-image-win style flags), it rewrites just its registry domain via TEKTON_REGISTRY_OVERRIDE.

Added TestDeploymentContainerArgsImagesRegistryOverrideFallback to pkg/reconciler/common/transformers_test.go, covering both a plain -bash-image arg and the real -shell-image-win flag shipped in the Tekton Pipeline controller manifest. Confirmed (by temporarily reverting the transformers.go change) that this test fails without the fix and passes with it.

Report: #3270

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

Fix `TEKTON_REGISTRY_OVERRIDE` not being applied to image
references passed as container args (e.g. entrypoint, nop,
workingdirinit, shell-image-win, and triggers' event-listener
sink images).

AI assistance: this change was drafted with Claude Code.

Fixes #3270

Motivation:
TEKTON_REGISTRY_OVERRIDE is documented as a way to rewrite the
registry for every image the operator deploys, but only
container.Image, Task step images, and StepAction images had a
fallback that applies it when no per-image env var is set. Images
passed as container CLI args (e.g. "-workingdirinit-image
<value>", "-el-image <value>", "-shell-image-win <value>") were
skipped by that fallback, so in an air-gapped install those
container args still pointed at the public upstream registries
(gcr.io, mcr.microsoft.com) even with TEKTON_REGISTRY_OVERRIDE
set, unless the user also set every documented per-image env var
individually. This matches the images the reporter listed as not
being rewritten. No crash or outage results; the effect is
ImagePullBackOff for those specific images in registry-restricted
clusters, and it did already have a documented per-image env var
workaround.

Approach:
replaceContainersArgsImage (pkg/reconciler/common/transformers.go)
only rewrote an arg's image when a matching per-image env var
existed. Add the same registry-override fallback already used by
replaceContainerImages/replaceStepsImages/replaceStepActionImages:
when no per-image override matches an arg whose flag name looks
like an image flag (contains "_image" once normalized, covering
both "-foo-image" and "-foo-image-win" style flags), rewrite just
its registry domain via TEKTON_REGISTRY_OVERRIDE.

Validation:
Added TestDeploymentContainerArgsImagesRegistryOverrideFallback to
pkg/reconciler/common/transformers_test.go, covering both a plain
"-bash-image" arg and the real "-shell-image-win" flag shipped in
the Tekton Pipeline controller manifest. Confirmed (by temporarily
reverting the transformers.go change) that this test fails without
the fix and passes with it.

  go build ./...
  go vet ./pkg/reconciler/common/...
  gofmt -l pkg/reconciler/common/transformers.go pkg/reconciler/common/transformers_test.go
  go test ./pkg/reconciler/common/... ./pkg/reconciler/kubernetes/tektonpipeline/... \
    ./pkg/reconciler/kubernetes/tektontrigger/... ./pkg/reconciler/openshift/tektontrigger/... \
    ./pkg/reconciler/openshift/common/...

All of the above pass. golangci-lint could not be downloaded in
this sandbox (checksum mismatch fetching the pinned release
binary, unrelated to this change); go vet and gofmt are clean.

Report: tektoncd#3270

```release-note
Fix `TEKTON_REGISTRY_OVERRIDE` not being applied to image
references passed as container args (e.g. entrypoint, nop,
workingdirinit, shell-image-win, and triggers' event-listener
sink images).
```

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 10, 2026
@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 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 added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.13%. Comparing base (aadfe5a) to head (8d0e821).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3885      +/-   ##
==========================================
- Coverage   26.13%   26.13%   -0.01%     
==========================================
  Files         465      465              
  Lines       24933    24937       +4     
==========================================
+ Hits         6516     6517       +1     
- Misses      17697    17698       +1     
- Partials      720      722       +2     
Flag Coverage Δ
unit-tests 26.13% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Rewrite image registry Not working

2 participants