Skip to content

OCPBUGS-94170: fix registry override matching and propagation to init containers#8877

Open
avollmer-redhat wants to merge 1 commit into
openshift:release-4.22from
avollmer-redhat:fix/OCPBUGS-94170-combined-backport-4.22
Open

OCPBUGS-94170: fix registry override matching and propagation to init containers#8877
avollmer-redhat wants to merge 1 commit into
openshift:release-4.22from
avollmer-redhat:fix/OCPBUGS-94170-combined-backport-4.22

Conversation

@avollmer-redhat

Copy link
Copy Markdown

Summary

Combined manual backport of #8509 and #8824 to release-4.22.

The cherry-pick bot could not create this backport automatically because the support/util/registryoverride/ package does not exist on release-4.22 (it was introduced on main by #8509), causing merge conflicts.

What this fixes

  1. Registry override substring matching bug (OCPBUGS-85585: tighten registry override matching to strict longest-prefix across release-image consumers #8509): RegistryMirrorProviderDecorator.Lookup() used strings.Replace which could match substrings inside hostnames (e.g. quay.io inside quay.io.example.com). Replaced with strict longest-prefix matching via new registryoverride.Replace() helper.

  2. Digest/tag separator handling (OCPBUGS-92034: fix registry override matching for digest and tag separators #8824): The strict matching from OCPBUGS-85585: tighten registry override matching to strict longest-prefix across release-image consumers #8509 only accepted / as a valid separator. Repository-level overrides failed to match digest-based references (repo@sha256:...). Fixed matchesPrefix() to also accept @ (digest) and : (tag, when source contains a path component).

  3. Init container image override propagation (OCPBUGS-85585: tighten registry override matching to strict longest-prefix across release-image consumers #8509): CPO-managed init containers (e.g. availability-prober) were not getting registry overrides applied because imageprovider.New() populated component images without running them through override logic. Added NewWithRegistryOverrides() and wired it into the HCP controller.

Root cause

Without these fixes, ValidatingAdmissionPolicies in Deny mode block HCP creation because CPO init containers still reference original registries (e.g. quay.io/redhat-user-workloads/...) instead of the configured mirror/ACR.

Changes

  • New: support/util/registryoverride/ package with Replace() and comprehensive tests (18 test cases)
  • Modified: support/releaseinfo/registry_mirror_provider.go — use registryoverride.Replace() instead of strings.Replace
  • Modified: control-plane-operator/.../imageprovider/imageprovider.go — add NewWithRegistryOverrides()
  • Modified: control-plane-operator/.../hostedcontrolplane_controller.go — wire NewWithRegistryOverrides with registry overrides from the release provider

Test plan

  • 18 unit tests for registryoverride.Replace covering boundary matching, longest-prefix, digest/tag separators, false-positive rejection, mutation safety
  • All existing releaseinfo tests pass
  • All existing imageprovider tests pass (compilation verified)

Related

/cc @muraee @sjenning @raelga

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 30, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@avollmer-redhat: This pull request references Jira Issue OCPBUGS-94170, which is valid.

7 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
  • release note type set to "Release Note Not Required"
  • dependent bug Jira Issue OCPBUGS-85585 is in the state Verified, which is one of the valid states (MODIFIED, ON_QA, VERIFIED)
  • dependent Jira Issue OCPBUGS-85585 targets the "5.0.0" version, which is one of the valid target versions: 5.0.0
  • bug has dependents

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

Combined manual backport of #8509 and #8824 to release-4.22.

The cherry-pick bot could not create this backport automatically because the support/util/registryoverride/ package does not exist on release-4.22 (it was introduced on main by #8509), causing merge conflicts.

What this fixes

  1. Registry override substring matching bug (OCPBUGS-85585: tighten registry override matching to strict longest-prefix across release-image consumers #8509): RegistryMirrorProviderDecorator.Lookup() used strings.Replace which could match substrings inside hostnames (e.g. quay.io inside quay.io.example.com). Replaced with strict longest-prefix matching via new registryoverride.Replace() helper.

  2. Digest/tag separator handling (OCPBUGS-92034: fix registry override matching for digest and tag separators #8824): The strict matching from OCPBUGS-85585: tighten registry override matching to strict longest-prefix across release-image consumers #8509 only accepted / as a valid separator. Repository-level overrides failed to match digest-based references (repo@sha256:...). Fixed matchesPrefix() to also accept @ (digest) and : (tag, when source contains a path component).

  3. Init container image override propagation (OCPBUGS-85585: tighten registry override matching to strict longest-prefix across release-image consumers #8509): CPO-managed init containers (e.g. availability-prober) were not getting registry overrides applied because imageprovider.New() populated component images without running them through override logic. Added NewWithRegistryOverrides() and wired it into the HCP controller.

Root cause

Without these fixes, ValidatingAdmissionPolicies in Deny mode block HCP creation because CPO init containers still reference original registries (e.g. quay.io/redhat-user-workloads/...) instead of the configured mirror/ACR.

Changes

  • New: support/util/registryoverride/ package with Replace() and comprehensive tests (18 test cases)
  • Modified: support/releaseinfo/registry_mirror_provider.go — use registryoverride.Replace() instead of strings.Replace
  • Modified: control-plane-operator/.../imageprovider/imageprovider.go — add NewWithRegistryOverrides()
  • Modified: control-plane-operator/.../hostedcontrolplane_controller.go — wire NewWithRegistryOverrides with registry overrides from the release provider

Test plan

  • 18 unit tests for registryoverride.Replace covering boundary matching, longest-prefix, digest/tag separators, false-positive rejection, mutation safety
  • All existing releaseinfo tests pass
  • All existing imageprovider tests pass (compilation verified)

Related

/cc @muraee @sjenning @raelga

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: e381aeac-69fa-403d-bf3a-d9a64d97ff5a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci openshift-ci Bot requested review from muraee, raelga and sjenning June 30, 2026 16:07
@avollmer-redhat

Copy link
Copy Markdown
Author

/label backport-risk-assessed

This is a combined manual backport of #8509 + #8824 as requested by @muraee in #8873.

Backport risk assessment: Low risk. The changes add a new leaf package (registryoverride) with no internal dependencies, fix a strings.Replace call to use strict prefix matching, and wire registry overrides into the image provider for init containers. All changes are additive — no existing behavior changes unless --registry-overrides is configured, and when it is, the fix ensures overrides are correctly applied to all images rather than using the broken substring matching.

@openshift-ci

openshift-ci Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@avollmer-redhat: The label(s) backport-risk-assessed cannot be applied or removed, because you are not in one of the allowed teams and are not an allowed user. Must be a member of one of these teams: openshift-patch-managers, openshift-staff-engineers, openshift-release-oversight, openshift-sustaining-engineers

Details

In response to this:

/label backport-risk-assessed

This is a combined manual backport of #8509 + #8824 as requested by @muraee in #8873.

Backport risk assessment: Low risk. The changes add a new leaf package (registryoverride) with no internal dependencies, fix a strings.Replace call to use strict prefix matching, and wire registry overrides into the image provider for init containers. All changes are additive — no existing behavior changes unless --registry-overrides is configured, and when it is, the fix ensures overrides are correctly applied to all images rather than using the broken substring matching.

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-sigs/prow repository.

@muraee

muraee commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci openshift-ci Bot added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area labels Jun 30, 2026
@avollmer-redhat avollmer-redhat force-pushed the fix/OCPBUGS-94170-combined-backport-4.22 branch from d62a7b1 to fb88a55 Compare June 30, 2026 21:57
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.73171% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.87%. Comparing base (5cb8735) to head (714067c).
⚠️ Report is 17 commits behind head on release-4.22.

Files with missing lines Patch % Lines
.../hostedcontrolplane/imageprovider/imageprovider.go 0.00% 11 Missing ⚠️
support/releaseinfo/registry_mirror_provider.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           release-4.22    #8877      +/-   ##
================================================
+ Coverage         35.45%   35.87%   +0.42%     
================================================
  Files               767      775       +8     
  Lines             93724    94768    +1044     
================================================
+ Hits              33226    33996     +770     
- Misses            57785    57991     +206     
- Partials           2713     2781      +68     
Files with missing lines Coverage Δ
...ostedcontrolplane/hostedcontrolplane_controller.go 36.78% <ø> (+0.02%) ⬆️
support/util/registryoverride/registryoverride.go 100.00% <100.00%> (ø)
support/releaseinfo/registry_mirror_provider.go 45.45% <0.00%> (+1.97%) ⬆️
.../hostedcontrolplane/imageprovider/imageprovider.go 60.00% <0.00%> (-15.00%) ⬇️

... and 31 files with indirect coverage changes

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

@avollmer-redhat avollmer-redhat force-pushed the fix/OCPBUGS-94170-combined-backport-4.22 branch from fb88a55 to 5153904 Compare July 1, 2026 15:23
…t containers

Combined manual backport of openshift#8509 and openshift#8824 to release-4.22.
Introduces strict longest-prefix registry override matching and
wires overrides into CPO init container image resolution.

@raelga raelga left a comment

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.

Cherry picks two already tested and shiped changes.

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 2, 2026
@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avollmer-redhat, muraee, raelga

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

The pull request process is described 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

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aks
/test e2e-aws
/test e2e-aws-upgrade-hypershift-operator
/test e2e-azure-self-managed
/test e2e-kubevirt-aws-ovn-reduced
/test e2e-v2-aws

@raelga

raelga commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

/retest

@avollmer-redhat

Copy link
Copy Markdown
Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@avollmer-redhat: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws 714067c link true /test e2e-aws
ci/prow/e2e-aks 714067c link true /test e2e-aks

Full PR test history. Your PR dashboard.

Details

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-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants