Skip to content

MCO-2146: do not use OSImageStream in Hypershift#5750

Open
cheesesashimi wants to merge 1 commit intoopenshift:mainfrom
cheesesashimi:zzlotnik/hypershift-osstream
Open

MCO-2146: do not use OSImageStream in Hypershift#5750
cheesesashimi wants to merge 1 commit intoopenshift:mainfrom
cheesesashimi:zzlotnik/hypershift-osstream

Conversation

@cheesesashimi
Copy link
Member

@cheesesashimi cheesesashimi commented Mar 9, 2026

- What I did

During Hypershift bootstrapping, the OSImageStream value for a given release should not (yet) be consumed.

- How to verify it

- Description for the changelog

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • OS image stream initialization now correctly requires a non-external control plane topology in addition to feature gate enablement.
  • Tests

    • Added test scenarios for Hypershift environments to ensure proper bootstrap behavior with external control planes.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 9, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 9, 2026
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 9, 2026

@cheesesashimi: This pull request references MCO-2146 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

- What I did

During Hypershift bootstrapping, the OSImageStream value for a given release should not (yet) be consumed.

- How to verify it

- Description for the changelog

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
Copy link
Contributor

openshift-ci bot commented Mar 9, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheesesashimi

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

The changes add OSImageStream factory dependency injection to the Bootstrap controller for improved testability, introduce a control plane topology condition check (non-external required) for OSImageStream enablement, and expand test coverage with factory-based testing patterns and a Hypershift-specific test scenario.

Changes

Cohort / File(s) Summary
Core Bootstrap Logic
pkg/controller/bootstrap/bootstrap.go
Added imageStreamFactory field and getImageStreamFactory() helper method for dependency injection. Updated OSImageStream enablement logic to require non-external control plane topology alongside feature gate check. Modified fetchOSImageStream to use injected factory instead of direct factory instantiation.
Test Suite & Infrastructure
pkg/controller/bootstrap/bootstrap_test.go
Introduced fakeImageStreamFactory type and setupForBootstrapTest helper function for controlled factory-based testing. Added TestBootstrapRunHypershift to verify OSImageStream behavior is disabled for Hypershift. Enhanced TestBootstrapRun with assertion of image stream values population and Ignition content verification.
Test Data
pkg/controller/bootstrap/testdata/bootstrap-hypershift/machineconfigcontroller-controllerconfig.yaml, pkg/controller/bootstrap/testdata/bootstrap/featuregate.yaml
Added Hypershift-specific test data file with ControllerConfig defining external topology configuration. Added OSStreams feature gate to enabled list in existing feature gate test data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: preventing OSImageStream usage during Hypershift bootstrapping, which aligns with the primary modifications in the code.
Stable And Deterministic Test Names ✅ Passed Tests use standard Go testing.T framework with static, deterministic test names and hard-coded subtest values, not dynamic Ginkgo-style identifiers.
Test Structure And Quality ✅ Passed Custom check targets Ginkgo-specific patterns but PR uses standard Go testing package, making the check inapplicable to this codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 9, 2026

@cheesesashimi: This pull request references MCO-2146 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

- What I did

During Hypershift bootstrapping, the OSImageStream value for a given release should not (yet) be consumed.

- How to verify it

- Description for the changelog

Summary by CodeRabbit

Release Notes

  • Bug Fixes

  • OS image stream initialization now correctly requires a non-external control plane topology in addition to feature gate enablement.

  • Tests

  • Added test scenarios for Hypershift environments to ensure proper bootstrap behavior with external control planes.

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.

@cheesesashimi
Copy link
Member Author

/test unit verify

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/controller/bootstrap/bootstrap_test.go (1)

198-198: Prefer a Go-side copy helper over cp here.

Shelling out to cp makes these tests depend on an external binary and an extra process. Go's standard library (os.ReadFile, os.WriteFile, filepath.Walk, filepath.WalkDir) handles both recursive directory copies (line 198) and single file copies (line 228) without external dependencies, keeping tests self-contained and more portable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/controller/bootstrap/bootstrap_test.go` at line 198, The test currently
shells out to "cp -r" (require.NoError(t, exec.Command("cp", "-r",
"testdata/bootstrap/.", srcDir).Run())) which introduces an external dependency;
replace this with a Go-side recursive copy helper used in the test (e.g.,
copyDir or copyFile helpers) that walks the source with filepath.WalkDir,
creates destination directories with os.MkdirAll, reads files with os.ReadFile
and writes with os.WriteFile (preserving file mode where appropriate via
os.FileMode), and use that helper in place of the exec.Command call as well as
for the single-file copy call around line 228 so the tests no longer rely on
external binaries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/controller/bootstrap/bootstrap_test.go`:
- Line 198: The test currently shells out to "cp -r" (require.NoError(t,
exec.Command("cp", "-r", "testdata/bootstrap/.", srcDir).Run())) which
introduces an external dependency; replace this with a Go-side recursive copy
helper used in the test (e.g., copyDir or copyFile helpers) that walks the
source with filepath.WalkDir, creates destination directories with os.MkdirAll,
reads files with os.ReadFile and writes with os.WriteFile (preserving file mode
where appropriate via os.FileMode), and use that helper in place of the
exec.Command call as well as for the single-file copy call around line 228 so
the tests no longer rely on external binaries.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 0efb797c-63e1-4bd6-adb8-027b3c21de94

📥 Commits

Reviewing files that changed from the base of the PR and between 7a8a698 and af45ad2.

📒 Files selected for processing (4)
  • pkg/controller/bootstrap/bootstrap.go
  • pkg/controller/bootstrap/bootstrap_test.go
  • pkg/controller/bootstrap/testdata/bootstrap-hypershift/machineconfigcontroller-controllerconfig.yaml
  • pkg/controller/bootstrap/testdata/bootstrap/featuregate.yaml

// Enable OSImageStreams if the FeatureGate is active and the deployment is not OKD
if osimagestream.IsFeatureEnabled(fgHandler) {
// Enable OSImageStreams if the FeatureGate is active and the control plane topology is not external (e.g., Hypershift)
if osimagestream.IsFeatureEnabled(fgHandler) && cconfig.Spec.Infra.Status.ControlPlaneTopology != apicfgv1.ExternalTopologyMode {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit surprissed about not needing the same check in other places, specially here https://github.com/openshift/machine-config-operator/blob/main/pkg/operator/osimagestream_ocp.go#L170, but not limited to that place only.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it would be needed in other places. The reason is because in HyperShift, the tenant clusters don't have a running MCO on them. Additionally, the MCD is only ran on-demand by the HyperShift in response to a config change.

@cheesesashimi
Copy link
Member Author

/test e2e-hypershift-techpreview

Copy link
Contributor

@pablintino pablintino left a comment

Choose a reason for hiding this comment

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

The change looks good to me.
Given that the osimagestream package is going to change a bit and https://github.com/openshift/machine-config-operator/pull/5750/changes#diff-78aad83f4838506d3b9ce960f12bb3c670b649ce5cd01603ed1fd2d00ba48d48R176 may require some small touches, what do you prefer to do, wait for the defaultStream PR to land and rebase this one or land this one now and adjust this in that PR? I don't mind rebasing my change on top of this content if we merge this PR soon.

@cheesesashimi
Copy link
Member Author

I think we should merge this one sooner rather than later. I'm fairly confident that this change addresses the root issue. The e2e-hypershift failure does not appear related to this change.

@cheesesashimi cheesesashimi marked this pull request as ready for review March 13, 2026 12:09
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 13, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 13, 2026

@cheesesashimi: 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-hypershift-techpreview af45ad2 link false /test e2e-hypershift-techpreview
ci/prow/e2e-gcp-op-ocl af45ad2 link false /test e2e-gcp-op-ocl
ci/prow/e2e-hypershift af45ad2 link true /test e2e-hypershift

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants