-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
OCPBUGS-41184: GCP Validate Disk and Instance Type #9043
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -73,20 +73,29 @@ func Validate(client API, ic *types.InstallConfig) error { | |||||
return allErrs.ToAggregate() | ||||||
} | ||||||
|
||||||
func validateInstanceType(fldPath *field.Path, instanceType string, validInstanceTypes []string, arch string) *field.Error { | ||||||
if len(validInstanceTypes) == 0 { | ||||||
return field.InternalError(fldPath, fmt.Errorf("no valid instance types found")) | ||||||
} | ||||||
|
||||||
func validateInstanceAndDiskType(fldPath *field.Path, diskType, instanceType, arch string) *field.Error { | ||||||
diskTypes := []string{} | ||||||
ok := false | ||||||
if instanceType != "" { | ||||||
family, _, _ := strings.Cut(instanceType, "-") | ||||||
acceptedInstanceTypes := sets.New(validInstanceTypes...) | ||||||
if !acceptedInstanceTypes.Has(family) { | ||||||
return field.NotSupported(fldPath.Child("type"), family, sets.List(acceptedInstanceTypes)) | ||||||
diskTypes, ok = gcp.DiskTypeToInstanceTypeMap[family] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if !ok { | ||||||
return field.NotFound(fldPath.Child("type"), family) | ||||||
} | ||||||
|
||||||
acceptedArmFamilies := sets.New("t2a") | ||||||
if arch == types.ArchitectureARM64 && !acceptedArmFamilies.Has(family) { | ||||||
return field.NotSupported(fldPath.Child("type"), family, sets.List(acceptedArmFamilies)) | ||||||
} | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if arch == types.ArchitectureARM64 && family != "t2a" { | ||||||
return field.InternalError(fldPath, fmt.Errorf("instance type %s requires %s architecture", instanceType, types.ArchitectureARM64)) | ||||||
if len(diskTypes) > 0 && diskType != "" { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if !sets.New(diskTypes...).Has(diskType) { | ||||||
return field.Invalid( | ||||||
fldPath.Child("diskType"), | ||||||
diskType, | ||||||
fmt.Sprintf("%s instance requires one of the following disk types: %v", instanceType, diskTypes), | ||||||
) | ||||||
} | ||||||
} | ||||||
return nil | ||||||
|
@@ -104,16 +113,8 @@ func ValidateInstanceType(client API, fieldPath *field.Path, project, region str | |||||
return append(allErrs, field.InternalError(nil, err)) | ||||||
} | ||||||
|
||||||
instanceTypes := []string{} | ||||||
ok := false | ||||||
if diskType != "" { | ||||||
instanceTypes, ok = gcp.DiskTypeToInstanceTypeMap[diskType] | ||||||
if !ok { | ||||||
return append(allErrs, field.NotFound(fieldPath.Child("diskType"), diskType)) | ||||||
} | ||||||
} | ||||||
if err := validateInstanceType(fieldPath, instanceType, instanceTypes, arch); err != nil { | ||||||
allErrs = append(allErrs, err) | ||||||
if fieldErr := validateInstanceAndDiskType(fieldPath, diskType, instanceType, arch); fieldErr != nil { | ||||||
return append(allErrs, fieldErr) | ||||||
} | ||||||
|
||||||
userZones := sets.New(zones...) | ||||||
|
@@ -226,18 +227,28 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList | |||||
} | ||||||
} | ||||||
} | ||||||
allErrs = append(allErrs, | ||||||
ValidateInstanceType( | ||||||
client, | ||||||
field.NewPath("controlPlane", "platform", "gcp"), | ||||||
ic.GCP.ProjectID, | ||||||
ic.GCP.Region, | ||||||
zones, | ||||||
cpDiskType, | ||||||
instanceType, | ||||||
controlPlaneReq, | ||||||
arch, | ||||||
)...) | ||||||
|
||||||
// The IOPS minimum Control plane requirements are not met for pd-standard machines. | ||||||
if cpDiskType == "pd-standard" { | ||||||
allErrs = append(allErrs, | ||||||
field.NotSupported(field.NewPath("controlPlane").Child("type"), | ||||||
cpDiskType, | ||||||
sets.List(gcp.ControlPlaneSupportedDisks)), | ||||||
) | ||||||
} else { | ||||||
allErrs = append(allErrs, | ||||||
ValidateInstanceType( | ||||||
client, | ||||||
field.NewPath("controlPlane", "platform", "gcp"), | ||||||
ic.GCP.ProjectID, | ||||||
ic.GCP.Region, | ||||||
zones, | ||||||
cpDiskType, | ||||||
instanceType, | ||||||
controlPlaneReq, | ||||||
arch, | ||||||
)...) | ||||||
} | ||||||
|
||||||
for idx, compute := range ic.Compute { | ||||||
fieldPath := field.NewPath("compute").Index(idx) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,13 +27,23 @@ var ( | |
// ComputeSupportedDisks contains the supported disk types for control plane nodes. | ||
ComputeSupportedDisks = sets.New(HyperDiskBalanced, PDBalanced, PDSSD, PDStandard) | ||
|
||
// DiskTypeToInstanceTypeMap contains a map where the key is the Disk Type, and the values are a list of | ||
// instance types that are supported by the installer and correlate to the Disk Type. | ||
// DiskTypeToInstanceTypeMap contains a map where the key is the Instance Type, and the | ||
// values are a list of disk types that are supported by the installer and correlate to the Instance Type. | ||
DiskTypeToInstanceTypeMap = map[string][]string{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name is now backwards, but I understand not wanting to rename it. |
||
PDStandard: {"a2", "e2", "n1", "n2", "n2d", "t2a", "t2d"}, | ||
PDSSD: {"a2", "a3", "c3", "c3d", "e2", "m1", "n1", "n2", "n2d", "t2a", "t2d"}, | ||
PDBalanced: {"a2", "a3", "c3", "c3d", "e2", "m1", "n1", "n2", "n2d", "t2a", "t2d"}, | ||
HyperDiskBalanced: {"c3", "c3d", "m1", "n4"}, | ||
"a2": {PDStandard, PDSSD, PDBalanced}, | ||
"a3": {PDSSD, PDBalanced}, | ||
"c2": {PDStandard, PDSSD, PDBalanced}, | ||
"c2d": {PDStandard, PDSSD, PDBalanced}, | ||
"c3": {PDSSD, PDBalanced, HyperDiskBalanced}, | ||
"c3d": {PDSSD, PDBalanced, HyperDiskBalanced}, | ||
"e2": {PDStandard, PDSSD, PDBalanced}, | ||
"m1": {PDSSD, PDBalanced, HyperDiskBalanced}, | ||
"n1": {PDStandard, PDSSD, PDBalanced}, | ||
"n2": {PDStandard, PDSSD, PDBalanced}, | ||
"n2d": {PDStandard, PDSSD, PDBalanced}, | ||
"n4": {HyperDiskBalanced}, | ||
"t2a": {PDStandard, PDSSD, PDBalanced}, | ||
"t2d": {PDStandard, PDSSD, PDBalanced}, | ||
} | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about inverting this
if
?