Skip to content

OCPBUGS-78995: Azure MachinePool: Accept OSImageID - #2931

Open
2uasimojo wants to merge 1 commit into
openshift:masterfrom
2uasimojo:OCPBUGS-78995/azure-mp-image-id
Open

OCPBUGS-78995: Azure MachinePool: Accept OSImageID#2931
2uasimojo wants to merge 1 commit into
openshift:masterfrom
2uasimojo:OCPBUGS-78995/azure-mp-image-id

Conversation

@2uasimojo

@2uasimojo 2uasimojo commented Jul 23, 2026

Copy link
Copy Markdown
Member

Previously hive optionally accepted OSImage, a marketplace image spec, in an Azure MachinePool. If omitted, the installer's MachineSets() generator would leave the image specifier blank and the machine-api-operator would attempt to inject a reasonable default. But in several cases, MAO didn't do a good job of this, resulting in failure to boot the Machines.

In cases where marketplace images were appropriate, this could be worked around by simply filling in the OSImage field. However, in environments with no access to the marketplace, or where RHCOS images were not present there, and the managed/gallery image defaults didn't work, the user would be stuck with no recourse but to abandon the MachinePool and manage MachineSets directly.

Here we add a new field to the Azure MachinePool API: OSImageID, a string which expects the URN of an image in any of the (three: marketplace, managed, gallery) supported formats. This gives the user the ability to work around any defaulting failure.

Summary by CodeRabbit

  • New Features
    • Azure machine pools can now set the OS image via osImageID using a managed or gallery image resource ID.
    • osImage and osImageID are mutually exclusive: when both are provided, osImageID takes precedence; when neither is set, a default image is injected.
  • Bug Fixes
    • Improved Azure machine-set OS image selection to honor osImageID directly and removed unnecessary image-discovery behavior.
    • Added safer handling for non-marketplace Azure image IDs.
  • Documentation
    • Updated CRD/OpenAPI schema descriptions and validation metadata for the new osImageID option.

@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. 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 Jul 23, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@2uasimojo: This pull request references Jira Issue OCPBUGS-78995, 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)

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

Details

In response to this:

Previously hive optionally accepted OSImage, a marketplace image spec, in an Azure MachinePool. If omitted, the installer's MachineSets() generator would leave the image specifier blank and the machine-api-operator would attempt to inject a reasonable default. But in several cases, MAO didn't do a good job of this, resulting in failure to boot the Machines.

In cases where marketplace images were appropriate, this could be worked around by simply filling in the OSImage field. However, in environments with no access to the marketplace, or where RHCOS images were not present there, and the managed/gallery image defaults didn't work, the user would be stuck with no recourse but to abandon the MachinePool and manage MachineSets directly.

Here we add a new field to the Azure MachinePool API: OSImageID, a string which expects the URN of an image in any of the (three: marketplace, managed, gallery) supported formats. This gives the user the ability to work around any defaulting failure.

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 requested review from jstuever and suhanime July 23, 2026 21:41
@openshift-ci

openshift-ci Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 2uasimojo

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 Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cda0000d-f3dd-4354-bdd6-ca6211e49048

📥 Commits

Reviewing files that changed from the base of the PR and between c570d0a and cfc76ae.

📒 Files selected for processing (10)
  • apis/hive/v1/azure/machinepool.go
  • config/crds/hive.openshift.io_machinepools.yaml
  • hack/app-sre/saas-template.yaml
  • pkg/azureclient/client.go
  • pkg/azureclient/mock/client_generated.go
  • pkg/controller/machinepool/azureactuator.go
  • pkg/controller/machinepool/azureactuator_test.go
  • vendor/github.com/openshift/hive/apis/hive/v1/azure/machinepool.go
  • vendor/github.com/openshift/installer/pkg/asset/machines/azure/azuremachines.go
  • vendor/github.com/openshift/installer/pkg/asset/machines/azure/machines.go
💤 Files with no reviewable changes (2)
  • pkg/azureclient/client.go
  • pkg/azureclient/mock/client_generated.go
🚧 Files skipped from review as they are similar to previous changes (6)
  • config/crds/hive.openshift.io_machinepools.yaml
  • apis/hive/v1/azure/machinepool.go
  • hack/app-sre/saas-template.yaml
  • vendor/github.com/openshift/hive/apis/hive/v1/azure/machinepool.go
  • pkg/controller/machinepool/azureactuator.go
  • pkg/controller/machinepool/azureactuator_test.go

📝 Walkthrough

Walkthrough

Azure MachinePool now accepts an Azure managed or gallery image resource ID through OSImageID. Machine-set generation passes this identifier to the installer, applies image precedence, removes legacy image-listing/gen2 detection, and updates schemas, vendored APIs, mocks, installer handling, and tests.

Changes

Azure OS image selection

Layer / File(s) Summary
MachinePool image contracts
apis/hive/v1/azure/machinepool.go, vendor/.../machinepool.go, config/crds/..., hack/app-sre/saas-template.yaml
Adds optional OSImageID and documents its relationship with OSImage and default image injection across API and schema definitions.
Image selection and installer wiring
pkg/controller/machinepool/azureactuator.go, pkg/azureclient/client.go, pkg/azureclient/mock/client_generated.go, vendor/.../azuremachines.go, vendor/.../machines.go
Uses OSImageID during machine-set installation, preserves marketplace image construction, removes legacy image-listing/gen2 detection contracts, and handles explicit Azure resource IDs.
Actuator test coverage
pkg/controller/machinepool/azureactuator_test.go
Removes image-listing mocks, adds managed/gallery image ID cases, verifies precedence, and updates zone error paths to use SKU listing.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MachinePool
  participant GenerateMachineSets
  participant installazure.MachineSets
  MachinePool->>GenerateMachineSets: provide OSImage and OSImageID
  GenerateMachineSets->>GenerateMachineSets: apply OSImageID precedence
  GenerateMachineSets->>installazure.MachineSets: pass image ID and generated image
Loading

Possibly related PRs

Suggested reviewers: jstuever, suhanime

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 matches the main change: adding OSImageID support for Azure MachinePool.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment on lines -144 to -162
// An image was not provided so check if the installer created a "gen2" image
// to determine if we should allow resultant machinesets to consume a "gen2" image.
gen2ImageExists, err := a.gen2ImageExists(ic.Platform.Azure.ClusterResourceGroupName(cd.Spec.ClusterMetadata.InfraID))
if err != nil {
return nil, false, err
}
if !gen2ImageExists {
// Modify capabilities to ensure that a V1 image is chosen by installazure.MachineSets()
// because a V2 image does not exist.
// The HyperVGeneration is germane to the instance/disk type and affects the image used
// for the instance. "-gen-2" will be appended to the image name by installazure.MachineSets()
// when the HyperVGenerations capability (comma separated list of HyperVGenerations) includes "V2".
//
// capabilities := map[string]string{
// "HyperVGenerations": "V1,V2",
// }
//
if _, ok := capabilities["HyperVGenerations"]; ok {
capabilities["HyperVGenerations"] = "V1"

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 was checking for managed (not gallery) images, and erroneously restricting the capabilities to V1 even when no such images were found. However, in recent versions of the vendored installer code, that capability wasn't even being consulted. TL;DR: this chunk of code was a no-op.

With this PR, we could have added a bunch of logic to try to paper over the MAO bug -- look for gallery images, look for managed images, validate the generation of the discovered image(s) against the VM size -- but decided it would be too difficult to prove coverage of all edge cases.

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.

Note: This is here so we can validate the fix, but will cause verify to fail. Ultimately we'll pick up this change via a legit revendor.

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

🤖 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/machinepool/azureactuator_test.go`:
- Line 39: Add test cases in the existing Azure actuator tests covering
OSImageID: verify OSImageID alone sets the final azureProvider.Image to the
explicit ID, and verify setting both OSImage and OSImageID logs the precedence
warning and does not apply the OSImage fields. Remove the TODO once both
scenarios are covered.

In `@pkg/controller/machinepool/azureactuator.go`:
- Line 129: Remove the placeholder comment `// TODO: le big comment here` from
the precedence logic in the Azure machine pool actuator, or replace it with
concise documentation that accurately describes the surrounding logic; do not
leave unfinished TODO text in shipped code.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: de541464-ee42-459b-ba9c-c41373e90bef

📥 Commits

Reviewing files that changed from the base of the PR and between 3b28262 and 6754cfd.

📒 Files selected for processing (7)
  • apis/hive/v1/azure/machinepool.go
  • pkg/azureclient/client.go
  • pkg/azureclient/mock/client_generated.go
  • pkg/controller/machinepool/azureactuator.go
  • pkg/controller/machinepool/azureactuator_test.go
  • vendor/github.com/openshift/hive/apis/hive/v1/azure/machinepool.go
  • vendor/github.com/openshift/installer/pkg/asset/machines/azure/azuremachines.go
💤 Files with no reviewable changes (2)
  • pkg/azureclient/mock/client_generated.go
  • pkg/azureclient/client.go

Comment thread pkg/controller/machinepool/azureactuator_test.go
Comment thread pkg/controller/machinepool/azureactuator.go Outdated
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.38%. Comparing base (3b28262) to head (cfc76ae).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/machinepool/azureactuator.go 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2931      +/-   ##
==========================================
- Coverage   50.51%   50.38%   -0.14%     
==========================================
  Files         282      282              
  Lines       34485    34454      -31     
==========================================
- Hits        17420    17359      -61     
- Misses      15707    15737      +30     
  Partials     1358     1358              
Files with missing lines Coverage Δ
pkg/azureclient/client.go 0.00% <ø> (ø)
pkg/azureclient/mock/client_generated.go 74.45% <ø> (-16.74%) ⬇️
pkg/controller/machinepool/azureactuator.go 80.80% <84.61%> (-2.88%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread apis/hive/v1/azure/machinepool.go Outdated

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

🧹 Nitpick comments (1)
pkg/controller/machinepool/azureactuator_test.go (1)

363-389: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Precedence test doesn't assert the "ignoring OSImage" warning log.

This case verifies the resulting image reflects OSImageID, but doesn't set expectedLogs to confirm azureactuator.go's logger.Warn("ignoring OSImage since OSImageID was provided") is actually emitted when both fields are set — this was part of the original ask for this precedence scenario.

♻️ Proposed addition
 			expectedImage: &machineapi.Image{
 				ResourceID: "/resourceGroups/bar/providers/Microsoft.Compute/galleries/gallery_baz/images/blah",
 			},
+			expectedLogs: []string{"ignoring OSImage since OSImageID was provided"},
 		},
🤖 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/machinepool/azureactuator_test.go` around lines 363 - 389, The
“osImageID takes precedence over osImage” case should also verify the warning
emitted when both image fields are configured. Update this test case’s
expectedLogs to include the “ignoring OSImage since OSImageID was provided”
warning, while preserving its existing image and replica assertions.
🤖 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.

Nitpick comments:
In `@pkg/controller/machinepool/azureactuator_test.go`:
- Around line 363-389: The “osImageID takes precedence over osImage” case should
also verify the warning emitted when both image fields are configured. Update
this test case’s expectedLogs to include the “ignoring OSImage since OSImageID
was provided” warning, while preserving its existing image and replica
assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d49ea3e9-2f8c-428e-8078-63173ee33f49

📥 Commits

Reviewing files that changed from the base of the PR and between 6754cfd and c570d0a.

📒 Files selected for processing (8)
  • apis/hive/v1/azure/machinepool.go
  • config/crds/hive.openshift.io_machinepools.yaml
  • hack/app-sre/saas-template.yaml
  • pkg/azureclient/client.go
  • pkg/azureclient/mock/client_generated.go
  • pkg/controller/machinepool/azureactuator.go
  • pkg/controller/machinepool/azureactuator_test.go
  • vendor/github.com/openshift/hive/apis/hive/v1/azure/machinepool.go
💤 Files with no reviewable changes (2)
  • pkg/azureclient/client.go
  • pkg/azureclient/mock/client_generated.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • vendor/github.com/openshift/hive/apis/hive/v1/azure/machinepool.go
  • pkg/controller/machinepool/azureactuator.go

Previously hive optionally accepted `OSImage`, a marketplace image spec,
in an Azure MachinePool. If omitted, the installer's MachineSets()
generator would leave the image specifier blank and the
machine-api-operator would attempt to inject a reasonable default. But
in several cases, MAO didn't do a good job of this, resulting in failure
to boot the Machines.

In cases where marketplace images were appropriate, this could be worked
around by simply filling in the `OSImage` field. However, in
environments with no access to the marketplace, or where RHCOS images
were not present there, and the managed/gallery image defaults didn't
work, the user would be stuck with no recourse but to abandon the
MachinePool and manage MachineSets directly.

Here we add a new field to the Azure MachinePool API: `OSImageID`, a
string which expects the resource path of an image in either managed or
gallery format. This gives the user the ability to work around any
defaulting failure.
@2uasimojo
2uasimojo force-pushed the OCPBUGS-78995/azure-mp-image-id branch from c570d0a to cfc76ae Compare July 24, 2026 21:13
@openshift-ci

openshift-ci Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

@2uasimojo: 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/verify cfc76ae link true /test verify
ci/prow/security cfc76ae link true /test security

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/severity-critical Referenced Jira bug's severity is critical 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants