Skip to content

Commit d83d3fc

Browse files
committed
Added dedicated hosts support for AWS
1 parent 30b37b0 commit d83d3fc

File tree

9 files changed

+107
-20
lines changed

9 files changed

+107
-20
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,4 @@ require (
371371
)
372372

373373
// go get github.com/vr4manta/api@SPLAT-2206
374-
replace github.com/openshift/api => github.com/vr4manta/api v0.0.0-20250918161809-165b8e86e744
374+
replace github.com/openshift/api => github.com/vr4manta/api v0.0.0-20250929154722-9355a7602b96

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ github.com/uudashr/iface v1.3.1 h1:bA51vmVx1UIhiIsQFSNq6GZ6VPTk3WNMZgRiCe9R29U=
623623
github.com/uudashr/iface v1.3.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg=
624624
github.com/vmware/govmomi v0.46.3 h1:zBn42Rl0WZBFhGao8Dy0MFRkbE4YNPqOu0OBd+ww6VM=
625625
github.com/vmware/govmomi v0.46.3/go.mod h1:uoLVU9zlXC4p4GmLVG+ZJmBC0Gn3Q7mytOJvi39OhxA=
626-
github.com/vr4manta/api v0.0.0-20250918161809-165b8e86e744 h1:JQyuG/nkNXpJCmZSRjnwVPiQ3+HqSYKo+jnBDl/BBHg=
627-
github.com/vr4manta/api v0.0.0-20250918161809-165b8e86e744/go.mod h1:SPLf21TYPipzCO67BURkCfK6dcIIxx0oNRVWaOyRcXM=
626+
github.com/vr4manta/api v0.0.0-20250929154722-9355a7602b96 h1:B1sDjz+OYr4DLrz2GpiC3o8+l//3V5XbdnXauKhD+6M=
627+
github.com/vr4manta/api v0.0.0-20250929154722-9355a7602b96/go.mod h1:SPLf21TYPipzCO67BURkCfK6dcIIxx0oNRVWaOyRcXM=
628628
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
629629
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
630630
github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU=

pkg/operator/operator_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ var (
4545
{Name: apifeatures.FeatureGateAzureWorkloadIdentity},
4646
{Name: apifeatures.FeatureGateVSphereMultiDisk},
4747
{Name: apifeatures.FeatureGateVSphereHostVMGroupZonal},
48+
{Name: apifeatures.FeatureGateAWSDedicatedHosts},
4849
}
4950

5051
enabledFeatureMap = map[string]bool{
51-
"MachineAPIMigration": true,
52-
"AzureWorkloadIdentity": true,
53-
"VSphereMultiDisk": true,
54-
"VSphereHostVMGroupZonal": true,
52+
"MachineAPIMigration": true,
53+
"AzureWorkloadIdentity": true,
54+
"VSphereMultiDisk": true,
55+
"VSphereHostVMGroupZonal": true,
56+
"FeatureGateAWSDedicatedHosts": true,
5557
}
5658
)
5759

pkg/webhooks/machine_webhook.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,13 @@ func validateAWS(m *machinev1beta1.Machine, config *admissionConfig) (bool, []st
868868
)
869869
}
870870

871+
// Check if host affinity is set. If so, we expect a Host ID to be set
872+
if providerSpec.HostAffinity != nil {
873+
if providerSpec.HostID == nil || len(*providerSpec.HostID) == 0 {
874+
errs = append(errs, field.Required(field.NewPath("spec.hostID"), "hostID must be set when hostAffinity is configured"))
875+
}
876+
}
877+
871878
if len(errs) > 0 {
872879
return false, warnings, errs
873880
}

pkg/webhooks/machine_webhook_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,67 @@ func TestMachineCreation(t *testing.T) {
316316
},
317317
expectedError: "",
318318
},
319+
{
320+
name: "configure host affinity with Host ID",
321+
platformType: osconfigv1.AWSPlatformType,
322+
clusterID: "aws-cluster",
323+
providerSpecValue: &kruntime.RawExtension{
324+
Object: &machinev1beta1.AWSMachineProviderConfig{
325+
AMI: machinev1beta1.AWSResourceReference{
326+
ID: ptr.To[string]("ami"),
327+
},
328+
InstanceType: "test",
329+
HostAffinity: ptr.To(machinev1beta1.HostAffinityAnyAvailable),
330+
HostID: ptr.To("h-09dcf61cb388b0149"),
331+
},
332+
},
333+
expectedError: "",
334+
},
335+
{
336+
name: "configure host affinity with invalid affinity",
337+
platformType: osconfigv1.AWSPlatformType,
338+
clusterID: "aws-cluster",
339+
providerSpecValue: &kruntime.RawExtension{
340+
Object: &machinev1beta1.AWSMachineProviderConfig{
341+
AMI: machinev1beta1.AWSResourceReference{
342+
ID: ptr.To[string]("ami"),
343+
},
344+
InstanceType: "test",
345+
HostAffinity: ptr.To(machinev1beta1.HostAffinity("invalid")),
346+
},
347+
},
348+
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostID: Required value: hostID must be set when hostAffinity is configured", // true
349+
},
350+
{
351+
name: "configure host affinity without Host ID",
352+
platformType: osconfigv1.AWSPlatformType,
353+
clusterID: "aws-cluster",
354+
providerSpecValue: &kruntime.RawExtension{
355+
Object: &machinev1beta1.AWSMachineProviderConfig{
356+
AMI: machinev1beta1.AWSResourceReference{
357+
ID: ptr.To[string]("ami"),
358+
},
359+
InstanceType: "test",
360+
HostAffinity: ptr.To(machinev1beta1.HostAffinityHost),
361+
},
362+
},
363+
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostID: Required value: hostID must be set when hostAffinity is configured", // true
364+
},
365+
{
366+
name: "hostID alone is valid",
367+
platformType: osconfigv1.AWSPlatformType,
368+
clusterID: "aws-cluster",
369+
providerSpecValue: &kruntime.RawExtension{
370+
Object: &machinev1beta1.AWSMachineProviderConfig{
371+
AMI: machinev1beta1.AWSResourceReference{
372+
ID: ptr.To[string]("ami"),
373+
},
374+
InstanceType: "test",
375+
HostID: ptr.To("h-1234567890abcdef0"),
376+
},
377+
},
378+
expectedError: "",
379+
},
319380
{
320381
name: "with Azure and a nil provider spec value",
321382
platformType: osconfigv1.AzurePlatformType,

vendor/github.com/openshift/api/machine/v1beta1/types_awsprovider.go

Lines changed: 25 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/machine/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/machine/v1beta1/zz_generated.swagger_doc_generated.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo
995995
github.com/openshift-eng/openshift-tests-extension/pkg/junit
996996
github.com/openshift-eng/openshift-tests-extension/pkg/util/sets
997997
github.com/openshift-eng/openshift-tests-extension/pkg/version
998-
# github.com/openshift/api v0.0.0-20250901120840-a638ff2e96fb => github.com/vr4manta/api v0.0.0-20250918161809-165b8e86e744
998+
# github.com/openshift/api v0.0.0-20250901120840-a638ff2e96fb => github.com/vr4manta/api v0.0.0-20250929154722-9355a7602b96
999999
## explicit; go 1.24.0
10001000
github.com/openshift/api
10011001
github.com/openshift/api/annotations
@@ -3649,4 +3649,4 @@ sigs.k8s.io/yaml/goyaml.v3
36493649
# k8s.io/apiserver => github.com/openshift/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20250716113245-b94367cabf3e
36503650
# k8s.io/kubelet => github.com/openshift/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20250716113245-b94367cabf3e
36513651
# k8s.io/kubernetes => github.com/openshift/kubernetes v1.30.1-0.20250716113245-b94367cabf3e
3652-
# github.com/openshift/api => github.com/vr4manta/api v0.0.0-20250918161809-165b8e86e744
3652+
# github.com/openshift/api => github.com/vr4manta/api v0.0.0-20250929154722-9355a7602b96

0 commit comments

Comments
 (0)