Skip to content

Commit 798f605

Browse files
Merge pull request #1430 from jhixson74/main_aws_gp3_throughput
CORS-4280: AWS: Add throughput validation for gp3 volumes
2 parents 1d78f2e + bb4779e commit 798f605

22 files changed

+728
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/onsi/ginkgo/v2 v2.27.2
2020
github.com/onsi/gomega v1.38.2
2121
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251105193959-75a0be5d9bd7
22-
github.com/openshift/api v0.0.0-20251111193948-50e2ece149d7
22+
github.com/openshift/api v0.0.0-20251120220512-cb382c9eaf42
2323
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235
2424
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250910145856-21d03d30056d
2525
github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20251029084908-344babe6a957

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ github.com/opencontainers/selinux v1.11.1 h1:nHFvthhM0qY8/m+vfhJylliSshm8G1jJ2jD
449449
github.com/opencontainers/selinux v1.11.1/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
450450
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251105193959-75a0be5d9bd7 h1:Z1swlS6b3Adm6RPhjqefs3DWnNFLDxRX+WC8GMXhja4=
451451
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251105193959-75a0be5d9bd7/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
452-
github.com/openshift/api v0.0.0-20251111193948-50e2ece149d7 h1:MemawsK6SpxEaE5y0NqO5sIX3yTLIIyP89w6DGKukAk=
453-
github.com/openshift/api v0.0.0-20251111193948-50e2ece149d7/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
452+
github.com/openshift/api v0.0.0-20251120220512-cb382c9eaf42 h1:Mo2FlDdoCZ+BE2W4C0lNcxEDeIIhfsYFP6vj4Sggp8w=
453+
github.com/openshift/api v0.0.0-20251120220512-cb382c9eaf42/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
454454
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 h1:9JBeIXmnHlpXTQPi7LPmu1jdxznBhAE7bb1K+3D8gxY=
455455
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235/go.mod h1:L49W6pfrZkfOE5iC1PqEkuLkXG4W0BX4w8b+L2Bv7fM=
456456
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250910145856-21d03d30056d h1:+sqUThLi/lmgT5/scmmjnS6+RZFtbdxRAscNfCPyLPI=

pkg/webhooks/machine_webhook.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,32 @@ func validateAWS(m *machinev1beta1.Machine, config *admissionConfig) (bool, []st
799799

800800
// TODO(alberto): Validate providerSpec.BlockDevices.
801801
// https://github.com/openshift/cluster-api-provider-aws/pull/299#discussion_r433920532
802+
for i, blockDevice := range providerSpec.BlockDevices {
803+
ebs := blockDevice.EBS
804+
if ebs == nil || ebs.VolumeType == nil || ebs.ThroughputMib == nil {
805+
continue
806+
}
807+
808+
throughputPath := field.NewPath("providerSpec", "blockDevices").Index(i).Child("ebs", "throughputMib")
809+
throughputValue := *ebs.ThroughputMib
810+
811+
if *ebs.VolumeType != "gp3" {
812+
errs = append(errs, field.Invalid(
813+
throughputPath,
814+
throughputValue,
815+
"only valid for gp3 volumes",
816+
))
817+
continue
818+
}
819+
820+
if throughputValue < 125 || throughputValue > 2000 {
821+
errs = append(errs, field.Invalid(
822+
throughputPath,
823+
throughputValue,
824+
"must be a value between 125 and 2000",
825+
))
826+
}
827+
}
802828

803829
switch providerSpec.Placement.Tenancy {
804830
case "", machinev1beta1.DefaultTenancy, machinev1beta1.DedicatedTenancy, machinev1beta1.HostTenancy:

pkg/webhooks/machine_webhook_test.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,90 @@ func TestMachineCreation(t *testing.T) {
451451
},
452452
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostPlacement.dedicatedHost.id: Invalid value: \"invalid\": id must start with 'h-' followed by 17 lowercase hexadecimal characters (0-9 and a-f)",
453453
},
454+
{
455+
name: "with VolumeType set to gp3 and Throughput set under minium value",
456+
platformType: osconfigv1.AWSPlatformType,
457+
clusterID: "aws-cluster",
458+
providerSpecValue: &kruntime.RawExtension{
459+
Object: &machinev1beta1.AWSMachineProviderConfig{
460+
AMI: machinev1beta1.AWSResourceReference{
461+
ID: ptr.To[string]("ami"),
462+
},
463+
BlockDevices: []machinev1beta1.BlockDeviceMappingSpec{
464+
{
465+
EBS: &machinev1beta1.EBSBlockDeviceSpec{
466+
VolumeType: ptr.To[string]("gp3"),
467+
ThroughputMib: ptr.To[int32](124),
468+
},
469+
},
470+
},
471+
},
472+
},
473+
expectedError: "must be a value between 125 and 2000",
474+
},
475+
{
476+
name: "with VolumeType set to gp3 and Throughput set over maxium value",
477+
platformType: osconfigv1.AWSPlatformType,
478+
clusterID: "aws-cluster",
479+
providerSpecValue: &kruntime.RawExtension{
480+
Object: &machinev1beta1.AWSMachineProviderConfig{
481+
AMI: machinev1beta1.AWSResourceReference{
482+
ID: ptr.To[string]("ami"),
483+
},
484+
BlockDevices: []machinev1beta1.BlockDeviceMappingSpec{
485+
{
486+
EBS: &machinev1beta1.EBSBlockDeviceSpec{
487+
VolumeType: ptr.To[string]("gp3"),
488+
ThroughputMib: ptr.To[int32](2001),
489+
},
490+
},
491+
},
492+
},
493+
},
494+
expectedError: "must be a value between 125 and 2000",
495+
},
496+
{
497+
name: "with VolumeType set to gp3 and Throughput set within range",
498+
platformType: osconfigv1.AWSPlatformType,
499+
clusterID: "aws-cluster",
500+
providerSpecValue: &kruntime.RawExtension{
501+
Object: &machinev1beta1.AWSMachineProviderConfig{
502+
AMI: machinev1beta1.AWSResourceReference{
503+
ID: ptr.To[string]("ami"),
504+
},
505+
BlockDevices: []machinev1beta1.BlockDeviceMappingSpec{
506+
{
507+
EBS: &machinev1beta1.EBSBlockDeviceSpec{
508+
VolumeType: ptr.To[string]("gp3"),
509+
ThroughputMib: ptr.To[int32](1000),
510+
},
511+
},
512+
},
513+
},
514+
},
515+
expectedError: "",
516+
},
517+
{
518+
name: "with Throughput set on non gp3 volume",
519+
platformType: osconfigv1.AWSPlatformType,
520+
clusterID: "aws-cluster",
521+
providerSpecValue: &kruntime.RawExtension{
522+
Object: &machinev1beta1.AWSMachineProviderConfig{
523+
AMI: machinev1beta1.AWSResourceReference{
524+
ID: ptr.To[string]("ami"),
525+
},
526+
BlockDevices: []machinev1beta1.BlockDeviceMappingSpec{
527+
{
528+
EBS: &machinev1beta1.EBSBlockDeviceSpec{
529+
VolumeType: ptr.To[string]("io1"),
530+
ThroughputMib: ptr.To[int32](124),
531+
},
532+
},
533+
},
534+
},
535+
},
536+
expectedError: "only valid for gp3 volumes",
537+
},
454538
{
455539
name: "with Azure and a nil provider spec value",
456540
platformType: osconfigv1.AzurePlatformType,

vendor/github.com/openshift/api/config/v1/types_infrastructure.go

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

vendor/github.com/openshift/api/config/v1/types_node.go

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

0 commit comments

Comments
 (0)