Skip to content

RFE-9669: Add spec.platform.aws.amiID to MachinePool - #2935

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
sadiquepp:RFE-9669-aws-machinepool-ami-id
Jul 31, 2026
Merged

RFE-9669: Add spec.platform.aws.amiID to MachinePool#2935
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
sadiquepp:RFE-9669-aws-machinepool-ami-id

Conversation

@sadiquepp

@sadiquepp sadiquepp commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Allow specifying a custom AMI directly on a MachinePool's AWS platform spec, rather than only through the existing, explicitly-unsupported hive.openshift.io/image-id-override annotation.

  • Add AMIID *string to apis/hive/v1/aws.MachinePoolPlatform.
  • In pkg/controller/machinepool/awsactuator.go, resolve the AMI in this order: spec.platform.aws.amiID, then the hive.openshift.io/image-id-override annotation (unchanged), then the existing master-machine lookup fallback.
  • Regenerate deepcopy, CRD manifests, and the app-sre SaaS template via make update.

Assisted-by: Claude (Anthropic)

Summary by CodeRabbit

  • New Features
    • AWS machine pools can now specify a custom worker boot image via the optional spec.platform.aws.amiID.
  • Bug Fixes
    • AMI/boot image selection now uses a clearer precedence: spec.platform.aws.amiID, then the existing cluster annotation (when set), then the existing master-based AMI resolution.
    • Improved handling to prevent boot image ID pointer aliasing during updates.
  • Documentation
    • Added a “Machine Pools” section explaining custom VM boot images, including an AWS amiID example.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 30, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 30, 2026

Copy link
Copy Markdown

@sadiquepp: This pull request references RFE-9669 which is a valid jira issue.

Details

In response to this:

Allow specifying a custom AMI directly on a MachinePool's AWS platform spec, rather than only through the existing, explicitly-unsupported hive.openshift.io/image-id-override annotation.

  • Add AMIID *string to apis/hive/v1/aws.MachinePoolPlatform.
  • In pkg/controller/machinepool/awsactuator.go, resolve the AMI in this order: spec.platform.aws.amiID, then the hive.openshift.io/image-id-override annotation (unchanged), then the existing master-machine lookup fallback.
  • Regenerate deepcopy, CRD manifests, and the app-sre SaaS template via make update.

Assisted-by: Claude (Anthropic)

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 jstuever July 30, 2026 06:44
@coderabbitai

coderabbitai Bot commented Jul 30, 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: Pro Plus

Run ID: cd9cca2b-ba5d-42f8-bf6a-85c04b6fad76

📥 Commits

Reviewing files that changed from the base of the PR and between d565406 and 59c38f2.

📒 Files selected for processing (8)
  • apis/hive/v1/aws/machinepool.go
  • apis/hive/v1/aws/zz_generated.deepcopy.go
  • config/crds/hive.openshift.io_machinepools.yaml
  • docs/using-hive.md
  • hack/app-sre/saas-template.yaml
  • pkg/controller/machinepool/awsactuator.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/machinepool.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/zz_generated.deepcopy.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/zz_generated.deepcopy.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/machinepool.go
  • docs/using-hive.md

📝 Walkthrough

Walkthrough

Adds an optional AWS amiID to MachinePools, exposes it through schemas and documentation, updates deepcopy handling, and makes NewAWSActuator prefer the configured AMI over annotation or master-based resolution.

Changes

AWS AMI override

Layer / File(s) Summary
AMI contract and exposure
apis/hive/v1/aws/machinepool.go, apis/hive/v1/aws/zz_generated.deepcopy.go, vendor/github.com/openshift/hive/apis/hive/v1/aws/*, config/crds/..., hack/app-sre/saas-template.yaml, docs/using-hive.md
Adds optional spec.platform.aws.amiID, deepcopy support, CRD and template schema entries, and AWS usage documentation.
AMI resolution precedence
pkg/controller/machinepool/awsactuator.go
NewAWSActuator prefers a non-empty MachinePool AMI ID, then the annotation override, then existing master-based AMI resolution.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MachinePool
  participant NewAWSActuator
  participant Annotation
  participant MasterMachine
  MachinePool->>NewAWSActuator: provide spec.platform.aws.amiID
  NewAWSActuator->>Annotation: read override when AMIID is unset
  NewAWSActuator->>MasterMachine: resolve AMI when overrides are unset
Loading

Suggested reviewers: dlom, jstuever, 2uasimojo

🚥 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 clearly states the core change: adding spec.platform.aws.amiID to MachinePool.
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

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.

@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 (2)
pkg/controller/machinepool/awsactuator.go (2)

65-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the injected logger for the new AMI message.

Line 68 calls package-level log.Infof, while this constructor otherwise uses the injected logger. This bypasses controller-specific logging configuration and context; use logger.Infof or a structured logger.WithField(...) call 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/awsactuator.go` around lines 65 - 69, Update the
AMI selection branch in the machine pool constructor to replace the
package-level log.Infof call with the injected logger, using logger.Infof or an
equivalent structured logger call while preserving the existing message and AMI
value.

65-88: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add tests for AMI precedence and fallback.

Cover spec AMI ID over annotation, annotation fallback when the field is nil or empty, and master-based resolution when neither override is present.

🤖 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/awsactuator.go` around lines 65 - 88, Add tests
covering AMI selection in the logic surrounding masterAMIRefByTag and
getAWSAMIID: verify a non-empty pool.Spec.Platform.AWS.AMIID takes precedence
over MachinePoolImageIDOverrideAnnotation, the annotation is used when the spec
field is nil or empty, and master-based resolution occurs when neither override
is set. Assert the selected AMI and relevant error behavior for each fallback
path.
🤖 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/awsactuator.go`:
- Around line 65-69: Update the AMI selection branch in the machine pool
constructor to replace the package-level log.Infof call with the injected
logger, using logger.Infof or an equivalent structured logger call while
preserving the existing message and AMI value.
- Around line 65-88: Add tests covering AMI selection in the logic surrounding
masterAMIRefByTag and getAWSAMIID: verify a non-empty
pool.Spec.Platform.AWS.AMIID takes precedence over
MachinePoolImageIDOverrideAnnotation, the annotation is used when the spec field
is nil or empty, and master-based resolution occurs when neither override is
set. Assert the selected AMI and relevant error behavior for each fallback path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c05c602-653c-48a4-9981-dafae7825ac9

📥 Commits

Reviewing files that changed from the base of the PR and between c0b802f and 6e5f9bd.

📒 Files selected for processing (8)
  • apis/hive/v1/aws/machinepool.go
  • apis/hive/v1/aws/zz_generated.deepcopy.go
  • config/crds/hive.openshift.io_machinepools.yaml
  • docs/using-hive.md
  • hack/app-sre/saas-template.yaml
  • pkg/controller/machinepool/awsactuator.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/machinepool.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/zz_generated.deepcopy.go

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.47%. Comparing base (c0b802f) to head (59c38f2).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/machinepool/awsactuator.go 14.28% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2935      +/-   ##
==========================================
- Coverage   50.51%   50.47%   -0.04%     
==========================================
  Files         282      282              
  Lines       34485    34679     +194     
==========================================
+ Hits        17420    17505      +85     
- Misses      15707    15815     +108     
- Partials     1358     1359       +1     
Files with missing lines Coverage Δ
pkg/controller/machinepool/awsactuator.go 77.02% <14.28%> (-0.85%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@2uasimojo 2uasimojo left a comment

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.

This looks great, thanks! A few minor notes inline.

Comment thread apis/hive/v1/aws/machinepool.go Outdated
Comment on lines +48 to +49
// existing behavior of resolving the AMI from the cluster's master machine (or from the
// hive.openshift.io/image-id-override annotation, if set).

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.

I think we should probably not mention the annotation at all in the official API docstring. In fact, with or very shortly after this PR, we may want to consider deprecating it.

Comment thread docs/using-hive.md Outdated

#### Customizing AMI Images

The AMI image to use for the worker nodes can be customized by specifying the `spec.platform.aws.amiID` field.

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.

AMI image

RAS syndrome.


This part of the document tries to be platform-agnostic as much as possible, even though many of the snippets necessarily use a specific platform's config as an example. Can we reword this to be more generic? Like:

#### Customizing VM boot images

By default, we try to determine an appropriate boot image for VMs defined through MachinePools.
For some platforms, a specific image can be supplied in the MachinePool spec.
For example, for AWS, the AMI ID can be specified as follows:

I just looked and it turns out Azure is the only other platform where we allow OS image customization. So we could include an Azure example as well. But in general we would prefer to let the API be authoritative rather than trying to keep this doc comprehensive.

var amiID string
if pool.Spec.Platform.AWS != nil && pool.Spec.Platform.AWS.AMIID != nil && *pool.Spec.Platform.AWS.AMIID != "" {
amiID = *pool.Spec.Platform.AWS.AMIID
log.Infof("using AMI from spec.platform.aws.amiID: %s", amiID)

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.

I agree with the rabbit that we should use logger rather than log here.

Also, prefer structured logging (logger.WithField("AMIID", amiID).Info("using AMI from spec.platform.aws.amiID"))

I recognize you're following the neighboring code... but if you wouldn't mind fixing up L71 similarly, that would be great 👍

@sadiquepp
sadiquepp force-pushed the RFE-9669-aws-machinepool-ami-id branch from 6e5f9bd to d565406 Compare July 30, 2026 14:32

@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

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

65-88: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add tests for the new AMI precedence contract.

The supplied test context covers the master-machine fallback but not NewAWSActuator selecting a spec AMIID over the annotation, or the annotation over fallback. Add or verify table-driven cases for those paths, including nil and empty spec values.

🤖 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/awsactuator.go` around lines 65 - 88, Add
table-driven tests covering AMI precedence in NewAWSActuator: a non-empty
spec.platform.aws.AMIID must override the annotation, a non-empty annotation
must override master-machine fallback, and nil or empty spec AMIID values must
continue to the annotation/fallback paths. Reuse the existing master-machine
fallback test setup and assert the selected AMI for each case.
🤖 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 `@apis/hive/v1/aws/machinepool.go`:
- Around line 46-50: Align the canonical AMIID documentation in the API source
with the intended fallback wording, then regenerate the Hive vendored type and
published machinepool CRD from the canonical Hive definitions. Do not edit
vendor/github.com/openshift/hive or the CRD directly; ensure all three artifacts
expose identical AMIID documentation.

---

Nitpick comments:
In `@pkg/controller/machinepool/awsactuator.go`:
- Around line 65-88: Add table-driven tests covering AMI precedence in
NewAWSActuator: a non-empty spec.platform.aws.AMIID must override the
annotation, a non-empty annotation must override master-machine fallback, and
nil or empty spec AMIID values must continue to the annotation/fallback paths.
Reuse the existing master-machine fallback test setup and assert the selected
AMI for each case.
🪄 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: Pro Plus

Run ID: d254f61b-6574-49fb-8723-ac3e299c6b9e

📥 Commits

Reviewing files that changed from the base of the PR and between 6e5f9bd and d565406.

📒 Files selected for processing (8)
  • apis/hive/v1/aws/machinepool.go
  • apis/hive/v1/aws/zz_generated.deepcopy.go
  • config/crds/hive.openshift.io_machinepools.yaml
  • docs/using-hive.md
  • hack/app-sre/saas-template.yaml
  • pkg/controller/machinepool/awsactuator.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/machinepool.go
  • vendor/github.com/openshift/hive/apis/hive/v1/aws/zz_generated.deepcopy.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • apis/hive/v1/aws/zz_generated.deepcopy.go
  • hack/app-sre/saas-template.yaml
  • docs/using-hive.md

Comment on lines +46 to +50

// AMIID is the AMI to use for machines in this pool. When omitted, Hive falls back to its
// existing behavior of determining an appropriate boot image for the platform.
// +optional
AMIID *string `json:"amiID,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Regenerate the dependent API artifacts from one canonical comment.

The AMIID documentation differs across the changed artifacts: vendor/github.com/openshift/hive/apis/hive/v1/aws/machinepool.go:47-49 and config/crds/hive.openshift.io_machinepools.yaml:125-127 describe master/annotation fallback, while this source uses generic fallback wording. Choose the canonical wording, then regenerate the vendored copy and CRD so the API source, vendored type, and published schema do not drift.

As per path instructions, the Hive vendored definitions must mirror the corresponding API definitions and CRDs must be generated from Hive types. Based on learnings, update the canonical source and regenerate vendored artifacts rather than editing vendor/ directly.

🤖 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 `@apis/hive/v1/aws/machinepool.go` around lines 46 - 50, Align the canonical
AMIID documentation in the API source with the intended fallback wording, then
regenerate the Hive vendored type and published machinepool CRD from the
canonical Hive definitions. Do not edit vendor/github.com/openshift/hive or the
CRD directly; ensure all three artifacts expose identical AMIID documentation.

Sources: Path instructions, Learnings

Allow specifying a custom AMI directly on a MachinePool's AWS platform
spec, rather than only through the existing, explicitly-unsupported
hive.openshift.io/image-id-override annotation.

- Add AMIID *string to apis/hive/v1/aws.MachinePoolPlatform.
- In pkg/controller/machinepool/awsactuator.go, resolve the AMI in
  this order: spec.platform.aws.amiID, then the
  hive.openshift.io/image-id-override annotation (unchanged), then
  the existing master-machine lookup fallback.
- Regenerate deepcopy, CRD manifests, and the app-sre SaaS template
  via make update.

Assisted-by: Claude (Anthropic)

Signed-off-by: Sadique <sadiqueklr@gmail.com>
@sadiquepp
sadiquepp force-pushed the RFE-9669-aws-machinepool-ami-id branch from d565406 to 59c38f2 Compare July 30, 2026 14:57
@2uasimojo

Copy link
Copy Markdown
Member

/lgtm
/approve

Thanks @sadiquepp!

/override ci/prow/security

See #2937

/hold to control merge order

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 2uasimojo, sadiquepp

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

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@2uasimojo: Overrode contexts on behalf of 2uasimojo: ci/prow/security

Details

In response to this:

/lgtm
/approve

Thanks @sadiquepp!

/override ci/prow/security

See #2937

/hold to control merge order

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.

@2uasimojo

Copy link
Copy Markdown
Member

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2026
@2uasimojo

Copy link
Copy Markdown
Member

I think this will rebase, retest, and then merge. We should no longer need to override security since #2937.

@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@sadiquepp: all tests passed!

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.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 6049a6d into openshift:master Jul 31, 2026
29 checks passed
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/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants