Skip to content

Commit c7353ef

Browse files
committed
AWS: Ensure throughput setting is configured correctly on gp3 volumes
1 parent f5cae1f commit c7353ef

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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", "ebs", "throughputMib")
809+
throughputValue := *ebs.ThroughputMib
810+
811+
if *ebs.VolumeType != "gp3" {
812+
errs = append(errs, field.Invalid(
813+
throughputPath,
814+
throughputValue,
815+
fmt.Sprintf("providerSpec.blockDevices[%d].ebs.throughputMib is only valid for gp3 volumes", i),
816+
))
817+
continue
818+
}
819+
820+
if throughputValue < 125 || throughputValue > 2000 {
821+
errs = append(errs, field.Invalid(
822+
throughputPath,
823+
throughputValue,
824+
fmt.Sprintf("providerSpec.blockDevices[%d].ebs.throughputMib must be a value between 125 and 2000", i),
825+
))
826+
}
827+
}
802828

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

0 commit comments

Comments
 (0)