From a9880ef1c6a6d4ca734b488c095e683380271717 Mon Sep 17 00:00:00 2001 From: wkutler Date: Thu, 1 Aug 2024 14:24:13 -0400 Subject: [PATCH] OCM-9885 | feat: add validation for node pool custom disk size Signed-off-by: wkutler --- pkg/machinepool/validations/disk_size.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/machinepool/validations/disk_size.go b/pkg/machinepool/validations/disk_size.go index aeb3c6d1..dc3f4010 100644 --- a/pkg/machinepool/validations/disk_size.go +++ b/pkg/machinepool/validations/disk_size.go @@ -17,6 +17,9 @@ const ( // machinePoolRootVolumeSizeMaxAsOf414 is the maximum size of the root volume as of 4.14 // 16 TiB - limit as of 4.14 machinePoolRootVolumeSizeMaxAsOf414 = 16384 + // constants for node pool root size validation + nodePoolRootAWSVolumeSizeMin = 128 + nodePoolRootAWSVolumeSizeMax = 16384 ) // ValidateMachinePoolRootDiskSize validates the root volume size for a machine pool in AWS. @@ -37,6 +40,19 @@ func ValidateMachinePoolRootDiskSize(version string, machinePoolRootVolumeSize i return nil } +// ValidateNodePoolRootDiskSize validates the root volume size for a node pool in AWS. +func ValidateNodePoolRootDiskSize(nodePoolRootVolumeSize int) error { + if nodePoolRootVolumeSize < nodePoolRootAWSVolumeSizeMin || + nodePoolRootVolumeSize > nodePoolRootAWSVolumeSizeMax { + return fmt.Errorf("Invalid root disk size: %d GiB. Must be between %d GiB and %d GiB.", + nodePoolRootVolumeSize, + nodePoolRootAWSVolumeSizeMin, + nodePoolRootAWSVolumeSizeMax) + } + + return nil +} + // getAWSVolumeMaxSize returns the maximum size of the root volume for a machine pool in AWS. func getAWSVolumeMaxSize(version string) (int, error) { version414, _ := semver.NewVersion("4.14.0")