Skip to content

OCPBUGS-78995: Azure MachinePool: Fix image gallery discovery - #2930

Closed
2uasimojo wants to merge 1 commit into
openshift:masterfrom
2uasimojo:OCPBUGS-78995/azure-mp-fix-gallery-discovery
Closed

OCPBUGS-78995: Azure MachinePool: Fix image gallery discovery#2930
2uasimojo wants to merge 1 commit into
openshift:masterfrom
2uasimojo:OCPBUGS-78995/azure-mp-fix-gallery-discovery

Conversation

@2uasimojo

@2uasimojo 2uasimojo commented Jul 22, 2026

Copy link
Copy Markdown
Member

Around 4.20, installer started using marketplace images. The logic in our azure MachinePool actuator was never updated for that, which was causing problems with downstream image defaulting.

This is part of a two-part fix (the other part in installer, picked up via the latest revendor) to force the installer code to use gallery images iff they exist; and otherwise use a default marketplace image.

Summary by CodeRabbit

  • New Features

    • Improved Azure machine image selection for ARM64 and AMD64 architectures.
    • Added support for automatically selecting compatible marketplace images based on VM generation.
    • Azure deployments can now use available gallery images, including appropriate Gen1 or Gen2 variants.
  • Bug Fixes

    • Improved fallback behavior when gallery images are unavailable.
    • Prevented incompatible image selections for Azure VM capabilities.

Around 4.20, installer started using marketplace images. The logic in
our azure MachinePool actuator was never updated for that, which was
causing problems with downstream image defaulting.

This is part of a two-part fix (the other part in installer, picked up
via the latest revendor) to force the installer code to use gallery
images iff they exist; and otherwise use a default marketplace image.
@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/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 22, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@2uasimojo: This pull request references Jira Issue OCPBUGS-78995, which is invalid:

  • expected the bug to target either version "5.0." or "openshift-5.0.", but it targets "4.22.0" instead

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:

Around 4.20, installer started using marketplace images. The logic in our azure MachinePool actuator was never updated for that, which was causing problems with downstream image defaulting.

This is part of a two-part fix (the other part in installer, picked up via the latest revendor) to force the installer code to use gallery images iff they exist; and otherwise use a default marketplace image.

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 dlom and suhanime July 22, 2026 21:45
@openshift-ci

openshift-ci Bot commented Jul 22, 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 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Azure machine pool generation now detects Azure gallery images, propagates instance architecture through installer image creation, and selects marketplace RHCOS image SKUs based on ARM64 versus AMD64 and Hyper-V generation.

Changes

Azure image selection

Layer / File(s) Summary
Gallery detection and installer wiring
pkg/controller/machinepool/azureactuator.go
Gallery image detection now distinguishes whether any gallery image exists and whether a gen2 image is available, adjusts Hyper-V capabilities when needed, and passes the resulting image marker to installazure.MachineSets.
Architecture detection and propagation
vendor/github.com/openshift/installer/pkg/asset/installconfig/azure/capabilities.go, vendor/github.com/openshift/installer/pkg/asset/machines/azure/machines.go
Azure capabilities are mapped to ARM64 or AMD64 and the architecture is passed through provider, mapiImage, and capzImage.
Marketplace image selection
vendor/github.com/openshift/installer/pkg/asset/machines/azure/azuremachines.go
Marketplace RHCOS image references now use architecture- and Hyper-V-generation-specific SKUs when no gallery image is supplied.

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

Sequence Diagram(s)

sequenceDiagram
  participant MachinePoolAzureActuator
  participant installazure.MachineSets
  participant provider
  participant capzImage
  MachinePoolAzureActuator->>MachinePoolAzureActuator: detect gallery images and set capabilities
  MachinePoolAzureActuator->>installazure.MachineSets: pass rhcosImg and capabilities
  installazure.MachineSets->>provider: generate machine image
  provider->>capzImage: pass architecture and Hyper-V generation
  capzImage-->>provider: return gallery or marketplace image reference
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing Azure MachinePool image gallery discovery.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@2uasimojo 2uasimojo Jul 22, 2026

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: Vendor changes are a temporary port of openshift/installer#10707 for testing purposes. They'll need to be pulled in via a proper revendor, on which the rest of this commit will need to be stacked. Meanwhile, they'll trigger verify failures. That's okay.

@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/machinepool/azureactuator.go`:
- Around line 247-265: The galleryImageExistsAndIsGen2 method currently queries
managed images through getImagesByResourceGroup, so replace that lookup with the
Azure Compute gallery image/version APIs for the specified resource group.
Preserve the existing found/gen2 return semantics and error wrapping while
evaluating the returned gallery image versions’ HyperVGeneration values.
🪄 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: 0fe2b469-6219-4420-8839-ac00cdafb3c1

📥 Commits

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

📒 Files selected for processing (4)
  • pkg/controller/machinepool/azureactuator.go
  • vendor/github.com/openshift/installer/pkg/asset/installconfig/azure/capabilities.go
  • vendor/github.com/openshift/installer/pkg/asset/machines/azure/azuremachines.go
  • vendor/github.com/openshift/installer/pkg/asset/machines/azure/machines.go

Comment on lines +247 to +265
// galleryImageExistsAndIsGen2 looks for gallery images in the specified RG.
// The first return indicates that we found *any* such images. If this is false, the caller should
// use marketplace images.
// The second return, only relevant if the first is true, indicates whether any of the found images
// are gen2. If this is false, the caller must assume gen1, validate compatibility with the VM
// size, and request gen1 accordingly.
func (a *AzureActuator) galleryImageExistsAndIsGen2(resourceGroupName string) (bool, bool, error) {
images, err := a.getImagesByResourceGroup(resourceGroupName)
if err != nil {
return false, errors.Wrapf(err, "error listing images by resourceGroup: %s", resourceGroupName)
// We get 200/[] rather than 404 if there are none, right?
return false, false, errors.Wrapf(err, "error listing images by resourceGroup: %s", resourceGroupName)
}
found := len(images) != 0
for _, image := range images {
if image.ImageProperties.HyperVGeneration == compute.HyperVGenerationTypesV2 {
return true, nil
return found, true, nil
}
}
return false, nil
return found, false, nil

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 | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate relevant symbols and inspect the surrounding implementation.
rg -n "galleryImageExistsAndIsGen2|getImagesByResourceGroup|Microsoft\.Compute/images|galleries/.*/images|image version|hyperVGeneration" pkg/controller/machinepool/azureactuator.go pkg/controller/machinepool -S

printf '\n--- azureactuator.go (selected ranges) ---\n'
sed -n '1,360p' pkg/controller/machinepool/azureactuator.go

Repository: openshift/hive

Length of output: 14561


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the exact API client used for image listing.
rg -n "func \(.*getImagesByResourceGroup|ImagesClient|ListByResourceGroup|ListByResourceGroupComplete|GalleryImagesClient|GalleryImageVersionsClient" pkg -S

Repository: openshift/hive

Length of output: 612


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read only the implementation of the image lookup helper and its call sites.
file=pkg/controller/machinepool/azureactuator.go
nl -ba "$file" | sed -n '210,320p'

printf '\n--- call sites ---\n'
rg -n "galleryImageExistsAndIsGen2\(" pkg/controller/machinepool -S

Repository: openshift/hive

Length of output: 192


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Print the relevant section with line numbers so we can inspect the caller behavior.
nl -ba pkg/controller/machinepool/azureactuator.go | sed -n '120,290p'

Repository: openshift/hive

Length of output: 192


Use the gallery API here, not managed images. getImagesByResourceGroup only lists Microsoft.Compute/images, so gallery images under Microsoft.Compute/galleries/... are never found and this path falls back to marketplace selection. Wire this through the gallery image/version APIs instead.

🤖 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.go` around lines 247 - 265, The
galleryImageExistsAndIsGen2 method currently queries managed images through
getImagesByResourceGroup, so replace that lookup with the Azure Compute gallery
image/version APIs for the specified resource group. Preserve the existing
found/gen2 return semantics and error wrapping while evaluating the returned
gallery image versions’ HyperVGeneration values.

@openshift-ci

openshift-ci Bot commented Jul 22, 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/security eaaf5f0 link true /test security
ci/prow/e2e eaaf5f0 link true /test e2e
ci/prow/verify eaaf5f0 link true /test verify
ci/prow/unit eaaf5f0 link true /test unit
ci/prow/e2e-azure eaaf5f0 link true /test e2e-azure
ci/prow/images eaaf5f0 link true /test images
ci/prow/e2e-pool eaaf5f0 link true /test e2e-pool
ci/prow/periodic-images eaaf5f0 link true /test periodic-images
ci/prow/coverage eaaf5f0 link true /test coverage

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.

@2uasimojo

Copy link
Copy Markdown
Member Author

/close

in favor of #2931.

@openshift-ci openshift-ci Bot closed this Jul 24, 2026
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@2uasimojo: Closed this PR.

Details

In response to this:

/close

in favor of #2931.

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.

@openshift-ci-robot

Copy link
Copy Markdown

@2uasimojo: This pull request references Jira Issue OCPBUGS-78995. The bug has been updated to no longer refer to the pull request using the external bug tracker.

Details

In response to this:

Around 4.20, installer started using marketplace images. The logic in our azure MachinePool actuator was never updated for that, which was causing problems with downstream image defaulting.

This is part of a two-part fix (the other part in installer, picked up via the latest revendor) to force the installer code to use gallery images iff they exist; and otherwise use a default marketplace image.

Summary by CodeRabbit

  • New Features

  • Improved Azure machine image selection for ARM64 and AMD64 architectures.

  • Added support for automatically selecting compatible marketplace images based on VM generation.

  • Azure deployments can now use available gallery images, including appropriate Gen1 or Gen2 variants.

  • Bug Fixes

  • Improved fallback behavior when gallery images are unavailable.

  • Prevented incompatible image selections for Azure VM capabilities.

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.

@2uasimojo
2uasimojo deleted the OCPBUGS-78995/azure-mp-fix-gallery-discovery branch July 24, 2026 20:25
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/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants