Skip to content

MCO-2163: use machine-config-osimagestream to avoid hard-coding image tag names#10416

Open
cheesesashimi wants to merge 2 commits intoopenshift:mainfrom
cheesesashimi:zzlotnik/add-machine-config-osimagestream-extract-binary
Open

MCO-2163: use machine-config-osimagestream to avoid hard-coding image tag names#10416
cheesesashimi wants to merge 2 commits intoopenshift:mainfrom
cheesesashimi:zzlotnik/add-machine-config-osimagestream-extract-binary

Conversation

@cheesesashimi
Copy link
Copy Markdown
Member

@cheesesashimi cheesesashimi commented Mar 20, 2026

This makes use of the new machine-config-osimagestream binary helper that was added to the MCO. The intent is to use this binary to look up the OS image pullspec for the default OS ImageStream.

@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 20, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bd10167-b300-4578-9b45-9b4625899c79

📥 Commits

Reviewing files that changed from the base of the PR and between 39538df and 2c71d2a.

📒 Files selected for processing (1)
  • data/data/bootstrap/files/usr/local/bin/node-image-pull.sh.template

Walkthrough

Changes modify CoreOS image resolution in the bootstrap process. The shell script now extracts and executes a binary from the machine-config-operator image to compute the pullspec and adds explicit cleanup/trapping. Supporting Go code updates the template data structure from StreamTag to an OSImageStream typed field and sets the default SCOS OS image stream to "centos-10".

Changes

Cohort / File(s) Summary
Bootstrap Shell Script
data/data/bootstrap/files/usr/local/bin/node-image-pull.sh.template
Replaced direct image stream tag query with a multi-step flow: repeatedly resolve machine-config-operator image via image_for, create a temp dir, extract the machine-config-osimagestream binary from the MCO image using podman create/cp, invoke that binary to compute COREOS_IMAGE via get os-image-pullspec, add retries and explicit cleanup (container/image removal, tempdir) registered via an EXIT trap.
Ignition Bootstrap Refactor
pkg/asset/ignition/bootstrap/common.go
Updated imports to use rhcosAsset for the RHCOS image asset, replaced bootstrapTemplateData.StreamTag string with OSImageStream types.OSImageStream, and derive OSImageStream from installConfig.Config.OSImageStream with fallback to rhcos.DefaultOSImageStream; removed earlier StreamTag computation.
RHCOS Defaults
pkg/rhcos/stream_scos.go
Changed DefaultOSImageStream constant from empty "" to "centos-10" for SCOS code paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 20, 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 openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 20, 2026
@cheesesashimi cheesesashimi force-pushed the zzlotnik/add-machine-config-osimagestream-extract-binary branch from ab08bb0 to 5f7f1bc Compare March 20, 2026 19:41
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 20, 2026
# Note: Proxy environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) are
# automatically inherited from the environment if set via /etc/profile.d/proxy.sh
until COREOS_IMAGE=$("${TEMP_DIR}/machine-config-osimagestream" \
get default-node-image \
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.

Well, we don't want the default OS image, we need to return the OS image install-config points too.
We need to pass it by using

type bootstrapTemplateData struct {

We can use this PR to remove the StreamTag field we won't use anymore.

Copy link
Copy Markdown
Member Author

@cheesesashimi cheesesashimi Mar 23, 2026

Choose a reason for hiding this comment

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

I removed the StreamTag field and tried to just use the OSImageStream field. Unless this field is explicitly set in the install-config, it will be empty. I pushed up a change that detects this case and sets it to rhcos.DefaultOSImageStream.

This made me think about what should be the source of truth for what the default OSImageStream is: Should it be the OSImageStream code in the MCO repo? Or should it be the installer code?

We can likely defer that decision for now because the way that both the installer and MCO code is written, it shouldn't matter much. Nevertheless, it is something we should think about.

Comment on lines +28 to +30
--authfile /root/.docker/config.json \
--per-host-certs /etc/containers/certs.d \
--registry-config /etc/containers/registries.conf); do
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.

Can't we rely on the defaults? (Just asking not a blocking question or ask for change)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In #10406, I don't think we can rely on the defaults since machine-config-osimagestream will be running containerized. However, I think we can rely on the defaults here. I need to look at https://github.com/containers/image to see if there is a SetDefaultValues() function someplace for types.SystemContext. If not, then I'll put these values into the machine-config-osimagestream entrypoint as the default values.

@cheesesashimi cheesesashimi force-pushed the zzlotnik/add-machine-config-osimagestream-extract-binary branch from 5f7f1bc to dddbd35 Compare March 23, 2026 17:30
Copy link
Copy Markdown
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

What's bad about hardcoding the images? Is it because there are potentially more streams than rhcos9 & rhcos10, and we don't want to teach the installer about all of those?

Comment thread data/data/bootstrap/files/usr/local/bin/node-image-pull.sh.template Outdated
@cheesesashimi cheesesashimi force-pushed the zzlotnik/add-machine-config-osimagestream-extract-binary branch 2 times, most recently from 43dd650 to fc89859 Compare March 23, 2026 21:57
@cheesesashimi cheesesashimi changed the title [WIP] use machine-config-osimagestream to avoid hard-coding image tag names MCO-2163: use machine-config-osimagestream to avoid hard-coding image tag names Mar 27, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Mar 27, 2026

@cheesesashimi: This pull request references MCO-2163 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:

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 jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 27, 2026
@cheesesashimi cheesesashimi force-pushed the zzlotnik/add-machine-config-osimagestream-extract-binary branch from fc89859 to 39538df Compare April 9, 2026 16:14
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 9, 2026

@cheesesashimi: This pull request references MCO-2163 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:

This makes use of the new machine-config-osimagestream binary helper that was added to the MCO. The intent is to use this binary to look up the OS image pullspec for the default OS ImageStream.

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 cheesesashimi marked this pull request as ready for review April 9, 2026 16:48
@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 Apr 9, 2026
@openshift-ci openshift-ci bot requested review from jhixson74 and rna-afk April 9, 2026 16:49
@cheesesashimi
Copy link
Copy Markdown
Member Author

/jira-refresh

Copy link
Copy Markdown

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/rhcos/stream_scos.go (1)

7-8: Don't widen types.OSImageStream with a SCOS-only literal

types.OSImageStream is documented and validated as rhel-9/rhel-10, but this default introduces "centos-10" under the same type. pkg/asset/ignition/bootstrap/common.go:402-430 now forwards that value into template data, so future code can no longer rely on the type’s declared value set. Prefer a separate internal string/enum for the MCO helper stream name instead of reusing the install-config type.

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

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

In `@pkg/rhcos/stream_scos.go` around lines 7 - 8, DefaultOSImageStream currently
broadens the allowed values of types.OSImageStream by assigning a SCOS-only
literal ("centos-10"); instead create a separate internal constant (e.g.,
scosMCOStreamName string or a dedicated type) for the SCOS/MCO helper stream and
revert DefaultOSImageStream to only valid types.OSImageStream values, then
update callers that currently consume DefaultOSImageStream (the code path that
forwards the stream into template data) to use the new internal constant for
SCOS-specific logic instead of the types.OSImageStream-typed constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@data/data/bootstrap/files/usr/local/bin/node-image-pull.sh.template`:
- Around line 13-20: The extraction can leave a dangling container named
mco-osimagestream if podman cp fails, so make the process idempotent: generate a
unique container name (e.g., CONTAINER_NAME variable instead of the fixed
mco-osimagestream), register cleanup with trap to remove the container and
TEMP_DIR on exit (successful or error) and run podman rm in the trap so cleanup
always happens even when set -e aborts; update the extraction block that uses
podman create, podman cp and podman rm (and the similar block at lines 37-38) to
use the new CONTAINER_NAME and the trap-based cleanup.

---

Nitpick comments:
In `@pkg/rhcos/stream_scos.go`:
- Around line 7-8: DefaultOSImageStream currently broadens the allowed values of
types.OSImageStream by assigning a SCOS-only literal ("centos-10"); instead
create a separate internal constant (e.g., scosMCOStreamName string or a
dedicated type) for the SCOS/MCO helper stream and revert DefaultOSImageStream
to only valid types.OSImageStream values, then update callers that currently
consume DefaultOSImageStream (the code path that forwards the stream into
template data) to use the new internal constant for SCOS-specific logic instead
of the types.OSImageStream-typed constant.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3c472bbc-f9be-4878-b286-c618bb3ef4a9

📥 Commits

Reviewing files that changed from the base of the PR and between 4acb8b9 and 39538df.

📒 Files selected for processing (3)
  • data/data/bootstrap/files/usr/local/bin/node-image-pull.sh.template
  • pkg/asset/ignition/bootstrap/common.go
  • pkg/rhcos/stream_scos.go

Comment thread data/data/bootstrap/files/usr/local/bin/node-image-pull.sh.template Outdated
until COREOS_IMAGE=$(image_for ${coreos_img}); do
echo 'Failed to query release image; retrying...'
# Get the Machine Config Operator image from the release payload
until MCO_IMAGE=$(image_for 'machine-config-operator'); do
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.

Hmm, but note this adds another image we have to pull down here before we get to pivot. So I expect this to slightly affect bootstrapping time.

I guess this is pretty far along now, but wouldn't a cleaner design here be to put the machine-config-osimagestream helper stuff in the CVO? It already has an image command (which is what image_for uses) that's very similar to what we need here. E.g. a new command like osimage --stream {{ .OSImageStream }} which returns the pullspec of the right OS image.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree that the CVO would be a better long-term place for this to live. The bigger problem that we'll need to solve is that there is some common code for working with OSImageStreams that would need to live in both the CVO and the MCO. And ideally, we'd be able to find a home for that code.

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.

Nothing a little golang package import can't solve I would think? :)

# Extract the machine-config-osimagestream binary from the MCO image. This avoids having to munge podman args, paths, env vars, etc.
podman create --name mco-osimagestream "${MCO_IMAGE}"
podman cp mco-osimagestream:/usr/bin/machine-config-osimagestream "${TEMP_DIR}/machine-config-osimagestream"
podman rm mco-osimagestream
Copy link
Copy Markdown
Member

@jlebon jlebon Apr 9, 2026

Choose a reason for hiding this comment

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

We need to be memory-conscious here because we could also be running live, which means that all that content is living in RAM. E.g. SNO has strict memory requirements.

So probably we want to just podman rmi the MCO image entirely here once we've extracted out the binary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a really good point, thanks!

Copy link
Copy Markdown
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Looks sane to me overall!

until COREOS_IMAGE=$(image_for ${coreos_img}); do
echo 'Failed to query release image; retrying...'
# Get the Machine Config Operator image from the release payload
until MCO_IMAGE=$(image_for 'machine-config-operator'); do
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.

Nothing a little golang package import can't solve I would think? :)

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jlebon
Once this PR has been reviewed and has the lgtm label, please assign zaneb for approval. For more information see the Code Review Process.

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

@cheesesashimi
Copy link
Copy Markdown
Member Author

/retest-required

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

@cheesesashimi: The following test 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-ovn 2c71d2a link true /test e2e-aws-ovn

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

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.

5 participants