Skip to content

OCPBUGS-87635: Fix MCP.status.osImageStream - #6154

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
pablintino:ocpbugs-87635
Jun 9, 2026
Merged

OCPBUGS-87635: Fix MCP.status.osImageStream#6154
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
pablintino:ocpbugs-87635

Conversation

@pablintino

@pablintino pablintino commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Closes: #OCPBUGS-87635

- What I did

The logic that computes the MCP .status.osImageStream was wrongly using the "old" status of the MCP instead of the status thas is currently computed for the MCP, leading to races where the rendered MC used to determine the osImageURL in use can be the old one instead of the current one leading to a wrong stream to be reported. This change also adds an explicit check of the source MCs to ensure that the logic doesn't report a osImageStream if a user provided osImageUrl is in place. This check is a formality.

- How to verify it

Run "[PolarionID:88366][Skipped:Disconnected] osImageStream should be empty when osImageURL is set" a few (more than 5) times to ensure it doesn't fail anymore.

- Description for the changelog

Fix the osImageStream status field of the MCPs to report based on the latest computed state.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced detection and handling of user-managed OS image configurations to prevent unintended system overrides.
    • OS image stream status reporting is now controlled via feature settings for more granular configuration management.

The logic that computes the MCP .status.osImageStream was wrongly using
the "old" status of the MCP instead of the status thas is currently
computed for the MCP, leading to races where the rendered MC used to
determine the osImageURL in use can be the old one instead of the
current one leading to a wrong stream to be reported.
This change also adds an explicit check of the source MCs to ensure that
the logic doesn't report a osImageStream if a user provided osImageUrl
is in place. This check is a formality.

Signed-off-by: Pablo Rodriguez Nava <git@amail.pablintino.eu>
@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/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 8, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@pablintino: This pull request references Jira Issue OCPBUGS-87635, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

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

Details

In response to this:

Closes: #OCPBUGS-87635

- What I did

The logic that computes the MCP .status.osImageStream was wrongly using the "old" status of the MCP instead of the status thas is currently computed for the MCP, leading to races where the rendered MC used to determine the osImageURL in use can be the old one instead of the current one leading to a wrong stream to be reported. This change also adds an explicit check of the source MCs to ensure that the logic doesn't report a osImageStream if a user provided osImageUrl is in place. This check is a formality.

- How to verify it

Run "[PolarionID:88366][Skipped:Disconnected] osImageStream should be empty when osImageURL is set" a few (more than 5) times to ensure it doesn't fail anymore.

- Description for the changelog

Fix the osImageStream status field of the MCPs to report based on the latest computed state.

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 8, 2026

Copy link
Copy Markdown

Walkthrough

This PR updates the OS image stream status calculation in the machine config controller. The getOSImageStream method now accepts the freshly computed status object, uses status-derived configuration names, detects user-managed OS images, and gates the status assignment behind a feature flag.

Changes

OS Image Stream Status Calculation

Layer / File(s) Summary
OS image stream method refactor and feature flag gating
pkg/controller/node/status.go
The getOSImageStream method signature is extended to accept the freshly calculated MachineConfigPoolStatus. It now derives the rendered configuration name from status.Configuration.Name instead of pool.Status.Configuration.Name. User-managed OS image detection is added by iterating over status.Configuration.Source and returning an empty OSImageStreamReference if any source MachineConfig has spec.osImageURL set. The caller conditionally assigns status.OSImageStream only when ctrl.osStreamsFgEnabled is enabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

lgtm, jira/severity-important, jira/valid-bug, jira/valid-reference

Suggested reviewers

  • yuqi-zhang
  • dkhater-redhat
  • umohnani8

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error Line 584 logs full osImageURL which could expose internal hostnames, registries, or embedded tokens in logs. Omit or redact the osImageURL parameter from the log message at line 584 to avoid exposing sensitive registry/URL information.
Test Structure And Quality ⚠️ Warning Missing test coverage for source MachineConfig lookup error in getOSImageStream. Current code uses continue which allows false positive status reporting. Add test verifying getOSImageStream returns empty reference when source MachineConfig retrieval fails, ensuring conservative fail-closed behavior.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the specific bug fix (osImageStream status field) being addressed, which aligns with the primary change described in the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All Ginkgo test names in the repository are stable and deterministic, with no dynamic content (timestamps, UUIDs, generated names, node/pod names, or variable interpolation) across 24 test files.
Microshift Test Compatibility ✅ Passed All 8 new Ginkgo e2e tests include [apigroup:machineconfiguration.openshift.io] tags, which automatically excludes them from MicroShift CI.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR does not add any Ginkgo e2e tests; repository uses standard Go testing package, not Ginkgo. Check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR only modifies status computation for MachineConfigPool.osImageStream in status.go; no deployment manifests, scheduling constraints, affinity rules, or topology-dependent code introduced.
Ote Binary Stdout Contract ✅ Passed PR changes only controller methods with no stdout writes, fmt.Print calls, or process-level code, thus no OTE Binary Stdout Contract violations detected.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only pkg/controller/node/status.go (controller logic) with no new Ginkgo e2e tests added, making this check not applicable.
No-Weak-Crypto ✅ Passed PR modifies getOSImageStream function to fix OSImageStream status computation. No weak cryptographic algorithms, custom crypto, or non-constant-time secret comparisons detected.
Container-Privileges ✅ Passed PR modifies only Go source code (pkg/controller/node/status.go). The container-privileges check applies only to K8s manifests/container configs, which are absent from this PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Command failed


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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 8, 2026
Comment on lines +535 to +536
// Use the current fresh status instead of the MCP's old one
renderedConfigName := status.Configuration.Name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note for the reviewer: This is the real fix for the issue.

}

// If any source MC has osImageURL set, the OS image is user-managed
for _, srcRef := range status.Configuration.Source {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note for the reviewer: This check is a formality but worth to do.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/controller/node/status.go`:
- Around line 558-560: The lookup error handling for the source MachineConfig
(variable srcRef) in pkg/controller/node/status.go should fail closed instead of
continuing and risking a false-positive OS image stream; when the get for the
source MachineConfig returns an error, set/return an empty reference for srcRef
(e.g., an empty ObjectReference) rather than executing continue so the status
logic treats this as a retrieval failure consistent with other failures (refer
to srcRef and pool in the status aggregation function).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c2b377b9-c470-4ee3-b505-a70bc303696a

📥 Commits

Reviewing files that changed from the base of the PR and between 62b06d2 and ea09355.

📒 Files selected for processing (1)
  • pkg/controller/node/status.go

Comment on lines +558 to +560
if err != nil {
klog.Warningf("Could not retrieve source MachineConfig %s for pool %s: %v", srcRef.Name, pool.Name, err)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fail closed when a source MachineConfig cannot be retrieved

If a source MC lookup fails, continue can incorrectly report an OS image stream (false positive) despite missing evidence that the pool is not user-managed. Return an empty reference on lookup error to keep status conservative and consistent with other retrieval failures in this function.

Proposed fix
 	for _, srcRef := range status.Configuration.Source {
 		srcMC, err := ctrl.mcLister.Get(srcRef.Name)
 		if err != nil {
 			klog.Warningf("Could not retrieve source MachineConfig %s for pool %s: %v", srcRef.Name, pool.Name, err)
-			continue
+			return mcfgv1.OSImageStreamReference{}
 		}
 		if srcMC.Spec.OSImageURL != "" {
 			klog.V(4).Infof("Source MachineConfig %s has osImageURL set, skipping OSImageStream status for pool %s", srcMC.Name, pool.Name)
 			return mcfgv1.OSImageStreamReference{}
 		}
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/controller/node/status.go` around lines 558 - 560, The lookup error
handling for the source MachineConfig (variable srcRef) in
pkg/controller/node/status.go should fail closed instead of continuing and
risking a false-positive OS image stream; when the get for the source
MachineConfig returns an error, set/return an empty reference for srcRef (e.g.,
an empty ObjectReference) rather than executing continue so the status logic
treats this as a retrieval failure consistent with other failures (refer to
srcRef and pool in the status aggregation function).


// getOSImageStream gets the OSImageStream for a pool based on the calculated updated and degraded state
func (ctrl *Controller) getOSImageStream(pool *mcfgv1.MachineConfigPool, isUpdated, isDegraded bool) mcfgv1.OSImageStreamReference {
func (ctrl *Controller) getOSImageStream(pool *mcfgv1.MachineConfigPool, status *mcfgv1.MachineConfigPoolStatus, isUpdated, isDegraded bool) mcfgv1.OSImageStreamReference {

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.

Why does the new param need to be a pointer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no strong reason to pass it as a pointer, as well as there's no strong reason to pass it by value as a copy. As a pointer, there's always a risk that the function at some point in the future performs unexpected modifications to the status. On the other hand, the cost of passing the pointer is almost zero. With the pass by value approach, the risk is partially mitigated as some fields are primitives, but a good amount of them are not, so to fully mitigate the risk we would need a deep copy at the cost of speed.

@isabella-janssen isabella-janssen left a comment

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.

/lgtm

This seems like a fair fix to me

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 8, 2026
@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-aws-ovn
/test e2e-aws-ovn-upgrade
/test e2e-gcp-op-ocl-part1
/test e2e-gcp-op-ocl-part2
/test e2e-gcp-op-part1
/test e2e-gcp-op-part2
/test e2e-gcp-op-single-node
/test e2e-hypershift

@openshift-ci

openshift-ci Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: isabella-janssen, pablintino

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:
  • OWNERS [isabella-janssen,pablintino]

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

@isabella-janssen

Copy link
Copy Markdown
Member

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 8, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@isabella-janssen: This pull request references Jira Issue OCPBUGS-87635, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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.

@pablintino

Copy link
Copy Markdown
Contributor Author

/retest-required

@ptalgulk01

Copy link
Copy Markdown
Contributor

Pre-merge verified:

Environment Setup:
Version: 5.0.0-0-2026-06-08-084838-test-ci-ln-qvv2ljb-latest
Platform: AWS

Run the below TC multiple times, the TC run without any error.

./machine-config-tests-ext run-test "[sig-mco][Suite:openshift/machine-config-operator/disruptive][Serial][Disruptive][OCPFeatureGate:OSStreams] MCO osImageStream [PolarionID:88366][Skipped:Disconnected] osImageStream should be empty when osImageURL is set [apigroup:machineconfiguration.openshift.io]"

/verified by @ptalgulk01
/label qe-approved

@openshift-ci openshift-ci Bot added the qe-approved Signifies that QE has signed off on this PR label Jun 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@pablintino: This pull request references Jira Issue OCPBUGS-87635, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

Closes: #OCPBUGS-87635

- What I did

The logic that computes the MCP .status.osImageStream was wrongly using the "old" status of the MCP instead of the status thas is currently computed for the MCP, leading to races where the rendered MC used to determine the osImageURL in use can be the old one instead of the current one leading to a wrong stream to be reported. This change also adds an explicit check of the source MCs to ensure that the logic doesn't report a osImageStream if a user provided osImageUrl is in place. This check is a formality.

- How to verify it

Run "[PolarionID:88366][Skipped:Disconnected] osImageStream should be empty when osImageURL is set" a few (more than 5) times to ensure it doesn't fail anymore.

- Description for the changelog

Fix the osImageStream status field of the MCPs to report based on the latest computed state.

Summary by CodeRabbit

  • Bug Fixes
  • Enhanced detection and handling of user-managed OS image configurations to prevent unintended system overrides.
  • OS image stream status reporting is now controlled via feature settings for more granular configuration management.

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.

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ptalgulk01: This PR has been marked as verified by @ptalgulk01.

Details

In response to this:

Pre-merge verified:

Environment Setup:
Version: 5.0.0-0-2026-06-08-084838-test-ci-ln-qvv2ljb-latest
Platform: AWS

Run the below TC multiple times, the TC run without any error.

./machine-config-tests-ext run-test "[sig-mco][Suite:openshift/machine-config-operator/disruptive][Serial][Disruptive][OCPFeatureGate:OSStreams] MCO osImageStream [PolarionID:88366][Skipped:Disconnected] osImageStream should be empty when osImageURL is set [apigroup:machineconfiguration.openshift.io]"

/verified by @ptalgulk01
/label qe-approved

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.

@openshift-ci

openshift-ci Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@pablintino: all tests passed!

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.

@openshift-merge-bot
openshift-merge-bot Bot merged commit ee994cd into openshift:main Jun 9, 2026
17 checks passed
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@pablintino: Jira Issue Verification Checks: Jira Issue OCPBUGS-87635
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-87635 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

Closes: #OCPBUGS-87635

- What I did

The logic that computes the MCP .status.osImageStream was wrongly using the "old" status of the MCP instead of the status thas is currently computed for the MCP, leading to races where the rendered MC used to determine the osImageURL in use can be the old one instead of the current one leading to a wrong stream to be reported. This change also adds an explicit check of the source MCs to ensure that the logic doesn't report a osImageStream if a user provided osImageUrl is in place. This check is a formality.

- How to verify it

Run "[PolarionID:88366][Skipped:Disconnected] osImageStream should be empty when osImageURL is set" a few (more than 5) times to ensure it doesn't fail anymore.

- Description for the changelog

Fix the osImageStream status field of the MCPs to report based on the latest computed state.

Summary by CodeRabbit

  • Bug Fixes
  • Enhanced detection and handling of user-managed OS image configurations to prevent unintended system overrides.
  • OS image stream status reporting is now controlled via feature settings for more granular configuration management.

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.

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

Fix included in release 5.0.0-0.nightly-2026-06-10-003138

@pablintino

Copy link
Copy Markdown
Contributor Author

/cherry-pick release-4.22

@openshift-cherrypick-robot

Copy link
Copy Markdown

@pablintino: new pull request created: #6164

Details

In response to this:

/cherry-pick release-4.22

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.

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. jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. 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. qe-approved Signifies that QE has signed off on this PR verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants