Skip to content

Conversation

vr4manta
Copy link
Contributor

@vr4manta vr4manta commented Sep 18, 2025

SPLAT-2206

Changes

  • Added static Dedicated Host support for AWS machines
  • Updated feature gate owner to rvanderp3 and component to splat

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 18, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 18, 2025

@vr4manta: This pull request references SPLAT-2206 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

SPLAT-2206

Changes

  • Added static Dedicated Host support for AWS machines
  • Updated feature gate owner to rvanderp3 and component to splat

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.

1 similar comment
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 18, 2025

@vr4manta: This pull request references SPLAT-2206 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

SPLAT-2206

Changes

  • Added static Dedicated Host support for AWS machines
  • Updated feature gate owner to rvanderp3 and component to splat

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.

Copy link
Contributor

openshift-ci bot commented Sep 18, 2025

Hello @vr4manta! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 18, 2025
@JoelSpeed
Copy link
Contributor

Does this API already exist upstream in CAPA?

@openshift-ci openshift-ci bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 18, 2025
@vr4manta
Copy link
Contributor Author

Does this API already exist upstream in CAPA?

@JoelSpeed Yes, this is already merged and pulled into OpenShift. Working on just the static version since dynamic is not finished upstream.

@everettraven
Copy link
Contributor

/assign

@vr4manta vr4manta changed the title SPLAT-2206: Added AWS dedicated host support [WIP] SPLAT-2206: Added AWS dedicated host support Sep 19, 2025
@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 Sep 19, 2025
Copy link
Contributor

openshift-ci bot commented Sep 19, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from everettraven. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@vr4manta vr4manta force-pushed the SPLAT-2206 branch 2 times, most recently from 0fcff1c to b088b27 Compare September 19, 2025 13:33
Comment on lines 113 to 116
// +kubebuilder:validation:Pattern=`^h-[0-9a-f]{17}$`
// +kubebuilder:validation:MaxLength=19
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include constraints, explained in plain sentences, in the GoDoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update this.


// hostID specifies the Dedicated Host on which the instance must be started.
// This field is mutually exclusive with DynamicHostAllocation.
// +kubebuilder:validation:Pattern=`^h-[0-9a-f]{17}$`
Copy link
Contributor

Choose a reason for hiding this comment

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

While I know that this is a machine API and as such the validations run through a webhook, we no longer recommend the use of the kubebuilder:validation:Pattern marker and prefer using the kubebuilder:validation:XValidation marker to write CEL expressions with more user-friendly error messages than what would be returned by the pattern marker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, i can make this change

// +kubebuilder:validation:MaxLength=19
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
HostID *string `json:"hostID,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between setting this to "" and omitting the field entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There should be no difference. I would assume this field is not set if user not intending to place instances into a dedicated host.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no difference, this should not be a pointer and should have a minimum length of 1. This is probably what the linter is complaining about.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is validated by Go based webhooks, and not openapi, the linter is wrong on this one.

If we make this not a pointer, then the Go code has no way to know if this was deliberately set to "" or not. We don't want "" to be valid, so this needs to be a pointer so that we can check that.

In this case (and future cases like this in these providerspec APIs) we will want to make exceptions to the serialization rules on the linter.

We may want to even disable the serialization rules on these particular APIs somehow 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I went into standard API review mode here and forgot this API is webhook validation 🤦

Thanks for catching that!

We may want to even disable the serialization rules on these particular APIs somehow

Can we do this via codegen configurations?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do this via codegen configurations?

No, but we should be able to disable using the .golangci-lint.yaml config, ideally we could have a different config for the APIs that act like this, these MAPI ones aren't the only ones (e.g. the aggregated APIs we support too)

// hostAffinity specifies the dedicated host affinity setting for the instance.
// When HostAffinity is set to host, an instance started onto a specific host always restarts on the same host if stopped.
// When HostAffinity is set to default, and you stop and restart the instance, it can be restarted on any available host.
// When HostAffinity is defined, HostID is required.
Copy link
Contributor

Choose a reason for hiding this comment

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

Whether it is set to host or default, hostID will be required?

Also, when referring to a field use the serialized form of the field name as that is what end-users would be familiar with:

Suggested change
// When HostAffinity is defined, HostID is required.
// When HostAffinity is defined, hostID is required.

Copy link
Contributor Author

@vr4manta vr4manta Sep 19, 2025

Choose a reason for hiding this comment

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

Yes, if hostID is set, this field will be could required. The idea was that if they do not set this field when hostID is set, it will default to host behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, hostID is required when hostAffinity is set to host and should be forbidden otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I'll make sure this godoc states this. I have the webhook logic doing this already.

// When HostAffinity is defined, HostID is required.
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
HostAffinity *HostAffinity `json:"hostAffinity,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if I don't supply this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will default to host. I have been playing with trying to make linter happy with the configs today (which I put this into WIP). I will update the godoc to reflect this default behavior shortly.

Copy link
Contributor

Choose a reason for hiding this comment

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

So are the options here actually omitted (i.e don't set hostAffinity and hostID to use default AWS affinity logic) and Host (i.e I want it to use be assigned to this host)?

Copy link
Contributor Author

@vr4manta vr4manta Sep 29, 2025

Choose a reason for hiding this comment

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

So I am discussing this with @rvanderp3 , "Default" we are gonna change to "AnyAvailable". I believe with the AWS API, the idea is this field dictates whether hostID is looked at or not. We are gonna confirm this and see what the behavior should be to clear up any confusions.

Comment on lines 119 to 127
// hostAffinity specifies the dedicated host affinity setting for the instance.
// When HostAffinity is set to host, an instance started onto a specific host always restarts on the same host if stopped.
// When HostAffinity is set to default, and you stop and restart the instance, it can be restarted on any available host.
// When HostAffinity is defined, HostID is required.
Copy link
Contributor

Choose a reason for hiding this comment

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

For enum fields we generally try to follow the pattern of:

hostAffinity ...
Allowed values are Host, Default, and omitted.
When set to Host, ...
When set to Default, ...
When omitted, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, i'll make this godoc update

)

// HostAffinity describes the host affinity of an EC2 Instance
// +kubebuilder:validation:Enum:=host;default;""
Copy link
Contributor

Choose a reason for hiding this comment

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

Enums should be CamelCase:

Suggested change
// +kubebuilder:validation:Enum:=host;default;""
// +kubebuilder:validation:Enum:=Host;Default;""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it should. I was copying what was in CAPA. I'll make these adjustments.

Comment on lines 375 to 377
// HostAffinity describes the host affinity of an EC2 Instance
// +kubebuilder:validation:Enum:=host;default;""
// +kubebuilder:default=""
Copy link
Contributor

Choose a reason for hiding this comment

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

How is setting "" different than omitting the field that uses this type altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an attempt to make linter happy. I'll see if I can drop this which is what I am attempting.

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

A couple small comments.

May have more pending the results of discussions on what the appropriate behaviors are when set to Host and AnyAvailable.

// When set, the value must be a valid AWS Dedicated Host ID in the form
// "h-" followed by 17 lowercase hexadecimal characters.
// The maximum length is 19 characters, and the field may be omitted.
// +kubebuilder:validation:XValidation:rule="self == null || self.matches('^h-[0-9a-f]{17}$')",message="hostID must match ^h-[0-9a-f]{17}$"
Copy link
Contributor

Choose a reason for hiding this comment

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

While this regex is pretty straightforward, we prefer to return a message that is a plain english description on a validation error here. Makes it more human readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I attempted to make this better. hopefully it makes more sense in non regex speak.

// +kubebuilder:validation:MaxLength=19
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
HostID *string `json:"hostID,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably add a min length here as well so that an empty string ("") isn't a valid value. Linter will complain about this because it isn't aware of the machine API nuance, but we can override that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add that. Thanks!

@vr4manta vr4manta changed the title [WIP] SPLAT-2206: Added AWS dedicated host support SPLAT-2206: Added AWS dedicated host support Oct 2, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 2, 2025
// hostID specifies the Dedicated Host on which the instance must be started.
// This field is mutually exclusive with DynamicHostAllocation.
// When set, the value must be a valid AWS Dedicated Host ID in the form
// "h-" followed by 17 lowercase hexadecimal characters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we specify what "hexadecimal characters" are succinctly? Maybe something like:

Suggested change
// "h-" followed by 17 lowercase hexadecimal characters.
// "h-" followed by 17 lowercase hexadecimal characters (0-9 and a-f).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update this

// This field is mutually exclusive with DynamicHostAllocation.
// When set, the value must be a valid AWS Dedicated Host ID in the form
// "h-" followed by 17 lowercase hexadecimal characters.
// The maximum length is 19 characters, and the field may be omitted.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean for this field to be omitted? We should make this clear for end-users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I shortened two sentences and left this in. I'll remove since it is marked optional

Comment on lines 111 to 131
// hostID specifies the Dedicated Host on which the instance must be started.
// This field is mutually exclusive with DynamicHostAllocation.
// When set, the value must be a valid AWS Dedicated Host ID in the form
// "h-" followed by 17 lowercase hexadecimal characters.
// The maximum length is 19 characters, and the field may be omitted.
// +kubebuilder:validation:XValidation:rule="self == null || self.matches('^h-[0-9a-f]{17}$')",message="hostID must start with 'h-' and end in 17 alphanumeric characters"
// +kubebuilder:validation:MaxLength=19
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
HostID *string `json:"hostID,omitempty"`

// hostAffinity specifies the dedicated host affinity setting for the instance.
// Valid values are "AnyAvailable", "Host", and omitted.
// When HostAffinity is set to "Host", an instance started onto a specific host always restarts on the same host if stopped.
// When HostAffinity is set to "AnyAvailable", and you stop and restart the instance, it can be restarted on any available host.
// When HostAffinity is omitted and HostID is defined, the instance is started onto the specified host.
// When HostAffinity is defined, HostID is required.
// +kubebuilder:validation:MaxLength=64
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
HostAffinity *HostAffinity `json:"hostAffinity,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The more I look at this, the more I wonder if this should be nested another level and follow the discriminated union pattern.

It might make it easier to have configuration options be like:

...
dedicatedHost:
  affinity: Host
  host:
    id: h-017afcd

and

...
dedicatedHost:
  affinity: AnyAvailable

Then we can enforce requirements like dedicateHost.host.id being required when setting dedicatedHost.affinity to Host and forbidding it otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I discussed with @rvanderp3 and we can make it this way.

// When HostAffinity is set to "AnyAvailable", and you stop and restart the instance, it can be restarted on any available host.
// When HostAffinity is omitted and HostID is defined, the instance is started onto the specified host.
// When HostAffinity is defined, HostID is required.
// +kubebuilder:validation:MaxLength=64
Copy link
Contributor

Choose a reason for hiding this comment

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

Max length isn't needed on enums, but the type alias would need the enum marker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to add that to make linter happy.

make: Leaving directory '/home/ngirard/GitProjects/api-ngirard/tools'
machine/v1beta1/types_awsprovider.go:130:2: maxlength: field HostAffinity type HostAffinity must have a maximum length, add kubebuilder:validation:MaxLength marker (kubeapilinter)
        HostAffinity *HostAffinity `json:"hostAffinity,omitempty"`
        ^
1 issues:
* kubeapilinter: 1

Copy link
Contributor

Choose a reason for hiding this comment

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

That is likely because you don't have the +kubebuilder:validation:Enum marker on the type that it is asking for the max length marker. The linter can also pick up usage of the enum marker to determine that the max length isn't necessary (inherently enforced by the longest allowed value)

// When set, the value must be a valid AWS Dedicated Host ID in the form
// "h-" followed by 17 lowercase hexadecimal characters.
// The maximum length is 19 characters, and the field may be omitted.
// +kubebuilder:validation:XValidation:rule="self == null || self.matches('^h-[0-9a-f]{17}$')",message="hostID must start with 'h-' and end in 17 alphanumeric characters"
Copy link
Contributor

@everettraven everettraven Oct 6, 2025

Choose a reason for hiding this comment

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

I don't think we need the self == null in the CEL expression. IIRC it just won't run the validation if the field is omitted, which it would be on a nil value (even though this goes through a webhook, having a correct expression here helps with future readers to understand the intent without confusion).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i can make that update.

@vr4manta vr4manta force-pushed the SPLAT-2206 branch 2 times, most recently from 06d98ae to 9589e77 Compare October 7, 2025 16:16
Copy link
Contributor

@everettraven everettraven 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 making the change to a discriminated union - I definitely like this direction better!

// When hostAffinity is set, host.hostID is required for "Host" and must be omitted for "AnyAvailable".
// +kubebuilder:validation:MaxLength=64
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

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

The "discriminant" should be required so an end user has to make an explicit decision here - hostAffinity is the discriminant here. Because the parent field is already optional it is safe to make this field required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if affinity should be outside the dedicated host section. This way, we use the DedicatedHost field and have ID under it.

...
hostAffinity: Host
dedicatedHost:
    id: h-017afcd

// - Host: the instance must run on a specific host; set host.hostID.
// - omitted: if host.hostID is set, the instance runs on that specific host; otherwise no host constraint is applied.
// When hostAffinity is set, host.hostID is required for "Host" and must be omitted for "AnyAvailable".
// +kubebuilder:validation:MaxLength=64
Copy link
Contributor

Choose a reason for hiding this comment

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

Discriminants are enums and do not need a MaxLength. On the HostAffinity Go type alias, add +kubebuilder:validation:Enum=AnyAvailable;Host and remove the +kubebuilder:validation:MaxLength marker from this set of markers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can, but i was hitting error on this before where it was requiring it. I"ll try again and see how it goes.

// +kubebuilder:validation:MaxLength=64
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
HostAffinity *HostAffinity `json:"hostAffinity,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Because this is now nested under a parent field called dedicatedHost we can probably just call this field affinity instead of hostAffinity. Calling it hostAffinity results in a "stutter" like dedicatedHost.hostAffinity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 370 to 374
// Valid values are "AnyAvailable", "Host", and omitted.
// - AnyAvailable: the platform selects any available dedicated host; do not set host.
// - Host: the instance must run on a specific host; set host.hostID.
// - omitted: if host.hostID is set, the instance runs on that specific host; otherwise no host constraint is applied.
// When hostAffinity is set, host.hostID is required for "Host" and must be omitted for "AnyAvailable".
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a general pattern we try to follow for consistency across OpenShift APIs.

Could we update this to look like this?:

hostAffinity selects how the instance is placed on a dedicate host.
Allowed values are AnyAvailable and Host.
When set to AnyAvailable, the platform selects any available dedicated host.
When set to Host, the instance must run on a specific host denoted by host.hostID.
host is required when hostAffinity is set to Host, and forbidden otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, i can remove formatting and use sentences.

// hostAffinity selects how the instance is placed on a dedicated host.
// Valid values are "AnyAvailable", "Host", and omitted.
// - AnyAvailable: the platform selects any available dedicated host; do not set host.
// - Host: the instance must run on a specific host; set host.hostID.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if Host makes the most sense here or if it is to stutter-y.

As an example:

dedicatedHost:
  hostAffinity: Host
  host:
    hostID: h-1326af

That has "host" 5 times in 4 lines.

Maybe something like:

dedicatedHost:
  affinity: Specific
  specific:
    id: h-1326af

is better here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well above we said remove host from affinity, but i do not like the "specific" being used. That feels very odd. So this goes back to not doing discriminating union due to how this is now looking more complex. With this, affinity states if it is to be assigned to a dedicated host and then we just need a field to specify the host ID. Currently we do not have other info for the host to provide so it may start to feel like overkill.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe taking a step back here would be helpful.

Maybe I misunderstood, but my interpretation was that the original hostAffinity value was meant to only be used with dedicated hosts. Is that incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you understand correctly. The complexity is coming from the discriminating union additions, but I just want to find verbage that makes sense and is clear. So allow me to explain history and ideas.

In the aws API (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/moving-instances-dedicated-hosts.html) it states the placement logic for an instance. Its confusing there too. Here is an example:

aws ec2 modify-instance-placement \
    --instance-id i-1234567890abcdef0 \
    --affinity host \
    --tenancy host \
    --host-id h-012a3456b7890cdef

So what we are adding / added in CAPA upstream was this: kubernetes-sigs/cluster-api-provider-aws#5548

So for MAPI, we are adding just enough so we can do the mapi2capi conversion logic so we can create these resources. Ideally I was hoping to keep our API similar for simplicity (the original concept at beginning of PR), but I am happy to have it follow the OCP ideals (I did similar things for CAPV stuff for multi disk and others). So with all of this, I do like the idea of using the discriminating union pattern. Building upon our ideas with thoughts on whats next to come might be to do a combination of our ideas with the following:

[Any Host Placement]

hostPlacement:
  hostAffinity: AnyAvailable

[Static Placement]

hostPlacement:
  hostAffinity: DedicatedHost
  DedicatedHost:
    id: h-abcdef0123456789a

[Dynamic Host Placement]

hostPlacement:
  hostAffinity: DynamicHost
  DynamicHost:
    tags:
    - app: myApp
    - department: whatever

Maybe this is more in line with what you are thinking. I know @rvanderp3 is working on adding dynamic host support upstream at the moment and that will require some additional data or changed fields. Maybe this better sets us up for that.

What are your thoughts?

Comment on lines +380 to +419
// host specifies a particular dedicated host when required by hostAffinity or when
// hostAffinity is omitted and you want to target a specific host.
// Must be omitted when hostAffinity is "AnyAvailable".
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want something more like:

host specifies the exact host that an instance should run on.
host is required when hostAffinity is set to Host, and forbidden otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll make the change.


type Host struct {
// hostID identifies the AWS Dedicated Host on which the instance must run.
// Use this when hostAffinity is "Host" or when hostAffinity is omitted and you want a specific host.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove affinity text here. We should already be gating usage of the parent field based on what the affinity value is set to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good

// +kubebuilder:validation:XValidation:rule="self.matches('^h-[0-9a-f]{17}$')",message="hostID must start with 'h-' followed by 17 lowercase hexadecimal characters (0-9 and a-f)"
// +kubebuilder:validation:MaxLength=19
// +openshift:enable:FeatureGate=AWSDedicatedHosts
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

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

With this new structure, I believe this should be a required field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can update this.

Copy link
Contributor

openshift-ci bot commented Oct 10, 2025

@vr4manta: 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 aab9734 link true /test verify
ci/prow/lint aab9734 link true /test lint

Full PR test history. Your PR dashboard.

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

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants