Skip to content

Conversation

@tanfengshuang
Copy link
Contributor

  1. Dynamic AMI Lookup
  • Queries existing MachineSets in openshift-machine-api namespace
  • Extracts AMI ID from the first MachineSet's providerSpec.value.ami.id
  • Falls back to region+version-based ConfigMap lookup if no MachineSets exist
  • Ensures storage nodes use the same AMI as compute nodes (matching architecture)
  1. Dynamic Instance Type Lookup
  • Extracts instance type from existing MachineSets
  • Automatically handles bare metal by replacing .metal with .2xlarge
  • Falls back to awsInstanceType ConfigMap value if no MachineSets found
  • Ensures architecture compatibility between AMI and instance type

  - Dynamically query AMI ID from existing MachineSets
  - Add dynamic instance type lookup with ARM64 support
  - Handle bare metal clusters by skipping MachineSet creation
  - Fixes AMI mismatch issue causing deployment failures in unsupported regions
  - Supports ARM64 (Graviton) and x86_64 architectures

Signed-off-by: Fengshuang Tan <[email protected]>
Copy link
Member

@dhaiducek dhaiducek left a comment

Choose a reason for hiding this comment

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

Thanks for the update @tanfengshuang! I'm not sure I'm familiar enough with this Policy to approve it, but I have a minor comment to consider!

Comment on lines +55 to +66
id: '{{- $dynamicAMI := "" -}}
{{- $machinesets := (lookup "machine.openshift.io/v1beta1" "MachineSet" "openshift-machine-api" "") -}}
{{- if $machinesets.items -}}
{{- if gt (len $machinesets.items) 0 -}}
{{- $dynamicAMI = (index $machinesets.items 0).spec.template.spec.providerSpec.value.ami.id -}}
{{- end -}}
{{- end -}}
{{- if $dynamicAMI -}}
{{ $dynamicAMI }}
{{- else -}}
{{ fromConfigMap "policies" "opp-settings" (printf "%s-%s" (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.platformStatus.aws.region (fromClusterClaim "openshiftversion-major-minor")) }}
{{- end -}}'
Copy link
Member

Choose a reason for hiding this comment

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

(Optional) Leveraging range directly could be a bit cleaner (and I think would cover the conditionals that are in place?):

id: >-
  {{ $dynamicAMI := "" -}}
  {{ range $machineset := (lookup "machine.openshift.io/v1beta1" "MachineSet" "openshift-machine-api" "").items -}}
    {{ $dynamicAMI = $machineset.spec.template.spec.providerSpec.value.ami.id -}}
    {{ break -}}
  {{ end -}}
  {{ defaultAMI := fromConfigMap "policies" "opp-settings" (printf "%s-%s" (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.platformStatus.aws.region (fromClusterClaim "openshiftversion-major-minor")) }}
  {{ default $defaultAMI $dynamicAMI -}}

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can improve this as we move forward. A lot of testing has been completed with the current templates.

@dhaiducek dhaiducek requested a review from gparvin December 16, 2025 16:46
@openshift-ci
Copy link

openshift-ci bot commented Dec 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gparvin, tanfengshuang

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-merge-bot openshift-merge-bot bot merged commit 572fe17 into open-cluster-management-io:main Dec 18, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants