Skip to content

OS Streams with image-service using rhcos version - #10742

Draft
giladravid16 wants to merge 1 commit into
openshift:masterfrom
giladravid16:os-streams
Draft

OS Streams with image-service using rhcos version#10742
giladravid16 wants to merge 1 commit into
openshift:masterfrom
giladravid16:os-streams

Conversation

@giladravid16

@giladravid16 giladravid16 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

  • New Features
    • Added OS stream selection for clusters and infrastructure environments.
    • Added OS stream metadata to available OS images, including default-stream indicators.
    • OS stream settings now propagate through cluster installation, infrastructure environment creation, updates, boot artifacts, and installer configuration.
    • Added validation for incompatible stream and cluster reference combinations.
  • Bug Fixes
    • Improved OS image matching, fallback behavior, and version handling across supported streams.
  • Documentation
    • Updated API schemas and resource definitions with OS stream fields, defaults, and inheritance behavior.

@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 Aug 3, 2026
@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown

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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. api-review Categorizes an issue or PR as actively needing an API review. labels Aug 3, 2026
@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giladravid16

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 Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Walkthrough

The change adds OS stream selection to cluster and InfraEnv APIs, CRDs, models, image metadata, and installer configuration. Image lookup now supports explicit, default, and legacy streams. Controllers, inventory, boot artifacts, and admission validation propagate and validate the selected stream.

Changes

OS stream contracts and schemas

Layer / File(s) Summary
API and backend models
api/..., models/...
Cluster, InfraEnv, AgentClusterInstall, and OS image types now expose OS stream fields and default-stream metadata.
CRD and REST schemas
config/crd/..., deploy/olm-catalog/manifests/..., restapi/embedded_spec.go, swagger.yaml
CRD and Swagger schemas define the new OS stream properties and their fallback behavior.

Stream-aware image resolution

Layer / File(s) Summary
OS image selection and version handling
internal/versions/osimages.go, internal/imageservice/urls.go
Image lookup accepts an OS stream, selects explicit or default streams, supports legacy metadata, and derives the image version from Version or OpenshiftVersion.
Resolution tests and mocks
internal/versions/*_test.go, internal/imageservice/url_test.go, internal/versions/mock_osimages.go
Tests cover stream selection, default errors, legacy images, lookup signatures, and image-version fallback behavior.

Resource propagation and artifact generation

Layer / File(s) Summary
Cluster and InfraEnv flows
internal/controller/controllers/..., internal/bminventory/..., cmd/agentbasedinstaller/register.go
Controllers and inventory resolve, persist, and pass OS streams through cluster and InfraEnv creation and updates.
Boot artifacts and install configuration
internal/host/hostcommands/..., internal/installcfg/builder/...
Boot artifact lookups use the InfraEnv stream, and generated install configuration includes OSImageStream.
Flow validation tests
internal/bminventory/inventory_test.go, internal/controller/controllers/infraenv_controller_test.go, internal/host/hostcommands/*_test.go
Existing image-service expectations and URL assertions now use stream-aware lookups and selected image versions.

InfraEnv admission validation

Layer / File(s) Summary
Admission rules and tests
pkg/webhooks/agentinstall/v1beta1/infraenv_admission_hook.go, pkg/webhooks/agentinstall/v1beta1/infraenv_admission_hook_test.go
Admission rejects ClusterRef with OSStream and validates OS stream additions against cluster installation state.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant InfraEnvController
  participant Inventory
  participant OSImages
  participant BootArtifacts

  Client->>InfraEnvController: submit InfraEnv with OSStream
  InfraEnvController->>Inventory: resolve and persist OSStream
  Inventory->>OSImages: request image by version, architecture, and stream
  OSImages-->>Inventory: return selected OS image
  Inventory->>BootArtifacts: generate URLs from image version
  BootArtifacts-->>Client: return boot artifact data
Loading
🚥 Pre-merge checks | ✅ 12 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains the template but omits the change summary, issue, motivation, dependencies, and meaningful testing details. Add the change summary, related issue, motivation, dependencies, and testing details; update the checklist to reflect the included unit tests.
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning New Ginkgo tests use bare error assertions without diagnostic messages, for example lines 183 and 213 in url_test.go and osimages_test.go. Add context-specific messages to each new error assertion, such as identifying the OS stream lookup or install-config generation operation.
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: OS Streams integration with the image service using the RHCOS version.
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 newly added Ginkgo titles are static literals; the admission table uses fixed literal names, with no generated IDs, timestamps, nodes, namespaces, or IPs in titles.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added. The changed Ginkgo files are unit tests under internal/ and pkg/, and no changed path is an e2e suite.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds only unit tests under internal/imageservice, internal/installcfg, and internal/versions; no new e2e tests or multi-node/HA assumptions were found.
Topology-Aware Scheduling Compatibility ✅ Passed The diff adds OS-stream data and image lookup logic only; changed YAML files are CRD schemas, and no new affinity, spread, selector, toleration, replica, or PDB constraints are introduced.
Ote Binary Stdout Contract ✅ Passed No OTE or openshift-tests binary exists, and the PR adds no process-level stdout writes; changed test diagnostics use GinkgoWriter.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Changed tests are package-level unit tests using local models, mocks, or fake clients; no IPv4 literals, IP parsing, external calls, or new e2e tests were added.
No-Weak-Crypto ✅ Passed The patch adds no MD5, SHA1, DES, RC4, Blowfish, ECB, or crypto APIs. The existing MD5 proxy hash is unchanged, and token-signing code is not modified.
Container-Privileges ✅ Passed The commit changes CRD and API schema files only; added lines contain no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root, or allowPrivilegeEscalation settings.
No-Sensitive-Data-In-Logs ✅ Passed Patch review found no new logs containing credentials, tokens, PII, customer data, or hostnames; added validation logs are generic and image errors contain only version, architecture, stream, or im...
✨ 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.

🔧 ast-grep (0.45.0)
internal/bminventory/inventory_test.go

ast-grep timed out on this file


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

@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: 3

🧹 Nitpick comments (1)
internal/imageservice/url_test.go (1)

176-194: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add test coverage for the error paths of OsImageVersion.

The new tests cover the "prefers Version" and "falls back to OpenshiftVersion" cases. OsImageVersion also returns an error for a nil osImage and for an osImage with both Version and OpenshiftVersion empty. Add tests for these two error paths.

♻️ Suggested additional test cases
It("errors when osImage is nil", func() {
    _, err := OsImageVersion(nil)
    Expect(err).Should(HaveOccurred())
})

It("errors when both Version and OpenshiftVersion are empty", func() {
    _, err := OsImageVersion(&models.OsImage{})
    Expect(err).Should(HaveOccurred())
})
🤖 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 `@internal/imageservice/url_test.go` around lines 176 - 194, Add two error-path
tests to the OsImageVersion Describe block: verify OsImageVersion(nil) returns
an error, and verify an empty models.OsImage with both Version and
OpenshiftVersion unset also returns an error.
🤖 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 `@internal/bminventory/inventory.go`:
- Line 2676: Update the cluster update flow around validateUpdateCluster and
updateClusterData to validate ClusterUpdateParams.OsStream against an available
OS image before optionalParam persists it to os_stream. Reject invalid streams
and preserve the existing write path for valid values.

In `@internal/controller/controllers/infraenv_controller.go`:
- Around line 203-205: Update
internal/controller/controllers/infraenv_controller.go lines 203-205 in
updateInfraEnv to pass cluster to getOSStream, compare the resolved stream
including ClusterRef fallback with internalInfraEnv.OsStream, and send the
update whenever they differ, including an empty result. Update
internal/bminventory/inventory.go lines 5762-5765 so a non-nil
InfraEnvUpdateParams.OsStream is persisted even when it is empty.

In `@internal/versions/osimages.go`:
- Around line 128-132: Update the comparator in the patchMatches sorting logic
to handle nil version pointers and propagate or explicitly handle every error
returned by version.NewVersion. Avoid dereferencing malformed OpenshiftVersion
values or calling GreaterThan with nil; preserve deterministic sorting while
ensuring a single invalid catalog entry cannot panic the OS image lookup.

---

Nitpick comments:
In `@internal/imageservice/url_test.go`:
- Around line 176-194: Add two error-path tests to the OsImageVersion Describe
block: verify OsImageVersion(nil) returns an error, and verify an empty
models.OsImage with both Version and OpenshiftVersion unset also returns an
error.
🪄 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: 0cfd5ad8-8cbd-49fb-a727-a1be48e39674

📥 Commits

Reviewing files that changed from the base of the PR and between f9cee86 and dd86f92.

⛔ Files ignored due to path filters (25)
  • api/v1beta1/zz_generated.deepcopy.go is excluded by !**/zz_generated*
  • api/vendor/github.com/openshift/assisted-service/models/cluster.go is excluded by !**/vendor/**
  • api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go is excluded by !**/vendor/**
  • api/vendor/github.com/openshift/assisted-service/models/infra_env.go is excluded by !**/vendor/**
  • api/vendor/github.com/openshift/assisted-service/models/infra_env_create_params.go is excluded by !**/vendor/**
  • api/vendor/github.com/openshift/assisted-service/models/infra_env_update_params.go is excluded by !**/vendor/**
  • api/vendor/github.com/openshift/assisted-service/models/os_image.go is excluded by !**/vendor/**
  • api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/cluster.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/infra_env.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/infra_env_create_params.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/infra_env_update_params.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/os_image.go is excluded by !**/vendor/**
  • client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go is excluded by !**/vendor/**
  • vendor/github.com/openshift/assisted-service/api/hiveextension/v1beta1/agentclusterinstall_types.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/api/v1beta1/agentserviceconfig_types.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/api/v1beta1/infraenv_types.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/cluster.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/cluster_create_params.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/infra_env.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/infra_env_create_params.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/infra_env_update_params.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/os_image.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (42)
  • api/hiveextension/v1beta1/agentclusterinstall_types.go
  • api/v1beta1/agentserviceconfig_types.go
  • api/v1beta1/infraenv_types.go
  • cmd/agentbasedinstaller/register.go
  • config/crd/bases/agent-install.openshift.io_agentserviceconfigs.yaml
  • config/crd/bases/agent-install.openshift.io_hypershiftagentserviceconfigs.yaml
  • config/crd/bases/agent-install.openshift.io_infraenvs.yaml
  • config/crd/bases/extensions.hive.openshift.io_agentclusterinstalls.yaml
  • config/crd/resources.yaml
  • deploy/olm-catalog/manifests/agent-install.openshift.io_agentserviceconfigs.yaml
  • deploy/olm-catalog/manifests/agent-install.openshift.io_hypershiftagentserviceconfigs.yaml
  • deploy/olm-catalog/manifests/agent-install.openshift.io_infraenvs.yaml
  • deploy/olm-catalog/manifests/extensions.hive.openshift.io_agentclusterinstalls.yaml
  • internal/bminventory/inventory.go
  • internal/bminventory/inventory_test.go
  • internal/bminventory/inventory_v2_handlers.go
  • internal/controller/controllers/agentserviceconfig_controller.go
  • internal/controller/controllers/clusterdeployments_controller.go
  • internal/controller/controllers/infraenv_controller.go
  • internal/controller/controllers/infraenv_controller_test.go
  • internal/host/hostcommands/download_boot_artifacts_cmd.go
  • internal/host/hostcommands/download_boot_artifacts_cmd_test.go
  • internal/host/hostcommands/instruction_manager_test.go
  • internal/imageservice/url_test.go
  • internal/imageservice/urls.go
  • internal/installcfg/builder/builder.go
  • internal/installcfg/builder/builder_test.go
  • internal/versions/api.go
  • internal/versions/mock_osimages.go
  • internal/versions/osimages.go
  • internal/versions/osimages_test.go
  • models/cluster.go
  • models/cluster_create_params.go
  • models/infra_env.go
  • models/infra_env_create_params.go
  • models/infra_env_update_params.go
  • models/os_image.go
  • models/v2_cluster_update_params.go
  • pkg/webhooks/agentinstall/v1beta1/infraenv_admission_hook.go
  • pkg/webhooks/agentinstall/v1beta1/infraenv_admission_hook_test.go
  • restapi/embedded_spec.go
  • swagger.yaml

optionalParam(params.ClusterUpdateParams.NoProxy, "no_proxy", updates)
optionalParam(params.ClusterUpdateParams.SSHPublicKey, "ssh_public_key", updates)
optionalParam(params.ClusterUpdateParams.Hyperthreading, "hyperthreading", updates)
optionalParam(params.ClusterUpdateParams.OsStream, "os_stream", updates)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -A160 -B10 'func \(b \*bareMetalInventory\) validateUpdateCluster' internal/bminventory
rg -n -A6 -B6 'OsStream|GetOsImage' internal/bminventory/inventory_test.go

Repository: openshift/assisted-service

Length of output: 43286


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- cluster update validation and OsStream references ---'
rg -n -A220 -B20 'func \(b \*bareMetalInventory\) validateAndUpdateClusterParams|OsStream|os_stream|GetOsImage' internal/bminventory/inventory.go internal/bminventory/*.go

printf '%s\n' '--- all repository references to cluster OS stream validation ---'
rg -n -i 'os.?stream|validate.*stream|stream.*image|GetOsImage' --glob '*.go' | head -n 300

Repository: openshift/assisted-service

Length of output: 50383


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- relevant definitions in inventory.go ---'
rg -n 'func \(b \*bareMetalInventory\) validateAndUpdateClusterParams|func \(b \*bareMetalInventory\) updateClusterData|OsStream|os_stream|GetOsImage' internal/bminventory/inventory.go

printf '%s\n' '--- validation helper implementations ---'
rg -n -A120 -B10 'func \(b \*bareMetalInventory\) validateAndUpdateClusterParams' internal/bminventory/inventory.go
rg -n -A180 -B10 'func \(b \*bareMetalInventory\) updateClusterData' internal/bminventory/inventory.go

Repository: openshift/assisted-service

Length of output: 17549


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- production OsStream references outside inventory.go ---'
rg -n -i 'os.?stream|stream.*os|os.*stream' --glob '*.go' --glob '!**/*_test.go' --glob '!internal/bminventory/inventory.go' | head -n 200

printf '%s\n' '--- update request model and generated validation references ---'
rg -n -i 'type .*ClusterUpdateParams|ClusterUpdateParams struct|OsStream' --glob '*.go' --glob '*.yaml' --glob '*.yml' --glob '*.json' | head -n 300

printf '%s\n' '--- nearby cluster registration and InfraEnv validation for comparison ---'
sed -n '580,620p' internal/bminventory/inventory.go
sed -n '5648,5682p' internal/bminventory/inventory.go

Repository: openshift/assisted-service

Length of output: 375


Validate OsStream before persisting it. validateUpdateCluster does not validate OsStream, but updateClusterData writes it directly to os_stream. Reject streams that do not match an available OS image before this write.

🤖 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 `@internal/bminventory/inventory.go` at line 2676, Update the cluster update
flow around validateUpdateCluster and updateClusterData to validate
ClusterUpdateParams.OsStream against an available OS image before optionalParam
persists it to os_stream. Reject invalid streams and preserve the existing write
path for valid values.

Comment on lines +203 to +205
if infraEnv.Spec.OSStream != "" && infraEnv.Spec.OSStream != internalInfraEnv.OsStream {
updateParams.InfraEnvUpdateParams.OsStream = &infraEnv.Spec.OSStream
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Propagate empty and inherited OS stream updates.

The controller and backend both treat an empty OS stream as a no-op. A standalone InfraEnv cannot revert from rhel-9 to the default stream. An InfraEnv with ClusterRef also remains pinned to its old stream when the referenced cluster stream changes.

  • internal/controller/controllers/infraenv_controller.go#L203-L205: resolve the effective stream with getOSStream, including the ClusterRef fallback, and send an update whenever it differs from internalInfraEnv.OsStream. Pass cluster into updateInfraEnv to do this.
  • internal/bminventory/inventory.go#L5762-L5765: when params.InfraEnvUpdateParams.OsStream != nil, persist its value even when the value is "".
📍 Affects 2 files
  • internal/controller/controllers/infraenv_controller.go#L203-L205 (this comment)
  • internal/bminventory/inventory.go#L5762-L5765
🤖 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 `@internal/controller/controllers/infraenv_controller.go` around lines 203 -
205, Update internal/controller/controllers/infraenv_controller.go lines 203-205
in updateInfraEnv to pass cluster to getOSStream, compare the resolved stream
including ClusterRef fallback with internalInfraEnv.OsStream, and send the
update whenever they differ, including an empty result. Update
internal/bminventory/inventory.go lines 5762-5765 so a non-nil
InfraEnvUpdateParams.OsStream is persisted even when it is empty.

Comment on lines +128 to +132
sort.Slice(patchMatches, func(i, j int) bool {
v1, _ := version.NewVersion(*patchMatches[i].OpenshiftVersion)
v2, _ := version.NewVersion(*patchMatches[j].OpenshiftVersion)
return v1.GreaterThan(v2)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard against nil *version.Version before calling GreaterThan.

version.NewVersion errors are discarded with _. If parsing fails for either patchMatches[i].OpenshiftVersion or patchMatches[j].OpenshiftVersion, v1 or v2 is nil, and v1.GreaterThan(v2) can panic inside sort.Slice. This crashes the OS image lookup on a single malformed catalog entry.

As per path instructions, Go files must "Never ignore error returns."

🐛 Proposed fix to handle parse errors safely
 	sort.Slice(patchMatches, func(i, j int) bool {
-		v1, _ := version.NewVersion(*patchMatches[i].OpenshiftVersion)
-		v2, _ := version.NewVersion(*patchMatches[j].OpenshiftVersion)
-		return v1.GreaterThan(v2)
+		v1, err1 := version.NewVersion(*patchMatches[i].OpenshiftVersion)
+		v2, err2 := version.NewVersion(*patchMatches[j].OpenshiftVersion)
+		if err1 != nil || err2 != nil {
+			return false
+		}
+		return v1.GreaterThan(v2)
 	})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sort.Slice(patchMatches, func(i, j int) bool {
v1, _ := version.NewVersion(*patchMatches[i].OpenshiftVersion)
v2, _ := version.NewVersion(*patchMatches[j].OpenshiftVersion)
return v1.GreaterThan(v2)
})
sort.Slice(patchMatches, func(i, j int) bool {
v1, err1 := version.NewVersion(*patchMatches[i].OpenshiftVersion)
v2, err2 := version.NewVersion(*patchMatches[j].OpenshiftVersion)
if err1 != nil || err2 != nil {
return false
}
return v1.GreaterThan(v2)
})
🤖 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 `@internal/versions/osimages.go` around lines 128 - 132, Update the comparator
in the patchMatches sorting logic to handle nil version pointers and propagate
or explicitly handle every error returned by version.NewVersion. Avoid
dereferencing malformed OpenshiftVersion values or calling GreaterThan with nil;
preserve deterministic sorting while ensuring a single invalid catalog entry
cannot panic the OS image lookup.

Source: Path instructions

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 6, 2026
@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown

PR needs rebase.

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.

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

Labels

api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant