Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-9885 | feat: add validation for node pool custom disk size #70

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/machinepool/validations/disk_size.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't that the same value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, is there a difference from topology or is it only an OCP thing? Should we separate just to be safer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we just want to keep them separate in case we want to change the requirements to be different for HCP. the minimum specifically may be lower than classic but for now I'm just using the same values as classic so we can get the API changes in sooner

// constants for node pool root size validation
nodePoolRootAWSVolumeSizeMin = 128
nodePoolRootAWSVolumeSizeMax = 16384
)

// ValidateMachinePoolRootDiskSize validates the root volume size for a machine pool in AWS.
Expand All @@ -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")
Expand Down
Loading