Skip to content

Commit 5e2eccc

Browse files
Merge pull request openshift#8773 from barbacbd/CORS-3580
CORS-3580: Update GCP Disk Types
2 parents 290c94f + fefa6b8 commit 5e2eccc

File tree

10 files changed

+59
-10
lines changed

10 files changed

+59
-10
lines changed

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ spec:
512512
- pd-balanced
513513
- pd-ssd
514514
- pd-standard
515+
- hyperdisk-balanced
515516
type: string
516517
encryptionKey:
517518
description: EncryptionKey defines the KMS key to be
@@ -1419,6 +1420,7 @@ spec:
14191420
- pd-balanced
14201421
- pd-ssd
14211422
- pd-standard
1423+
- hyperdisk-balanced
14221424
type: string
14231425
encryptionKey:
14241426
description: EncryptionKey defines the KMS key to be used
@@ -3050,6 +3052,7 @@ spec:
30503052
- pd-balanced
30513053
- pd-ssd
30523054
- pd-standard
3055+
- hyperdisk-balanced
30533056
type: string
30543057
encryptionKey:
30553058
description: EncryptionKey defines the KMS key to be used

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ require (
244244
github.com/opencontainers/image-spec v1.1.0 // indirect
245245
github.com/opencontainers/runtime-spec v1.2.0 // indirect
246246
github.com/openshift/custom-resource-status v1.1.2 // indirect
247-
github.com/openshift/machine-api-operator v0.2.1-0.20240702095949-e959540b5ab8 // indirect
247+
github.com/openshift/machine-api-operator v0.2.1-0.20240722145313-3a817c78946a // indirect
248248
github.com/opentracing/opentracing-go v1.2.0 // indirect
249249
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
250250
github.com/pierrec/lz4/v4 v4.1.17 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,8 +2007,8 @@ github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a h1:E+XPJs/aVvY
20072007
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a/go.mod h1:E1bgquRiwfugdArdecPbpYIrAdve5kTzMaJb0+8jMXI=
20082008
github.com/openshift/library-go v0.0.0-20240207105404-126b47137408 h1:Evg6GEvEuyj9toFX14YenXI6hGRnhLWqYx/rHO7VnQ4=
20092009
github.com/openshift/library-go v0.0.0-20240207105404-126b47137408/go.mod h1:ePlaOqUiPplRc++6aYdMe+2FmXb2xTNS9Nz5laG2YmI=
2010-
github.com/openshift/machine-api-operator v0.2.1-0.20240702095949-e959540b5ab8 h1:l3gj7u1YqFPHE1kftlNtslHddG6RBFsAnGD/xRCohGo=
2011-
github.com/openshift/machine-api-operator v0.2.1-0.20240702095949-e959540b5ab8/go.mod h1:0hQJFbHS+qy1WY1/lmQpb1tizytRws+IJxGwbtHBqt4=
2010+
github.com/openshift/machine-api-operator v0.2.1-0.20240722145313-3a817c78946a h1:0TwU3J28sQTGy/ZMVSvi3sUolH92BwlIWcf+wCJLWKE=
2011+
github.com/openshift/machine-api-operator v0.2.1-0.20240722145313-3a817c78946a/go.mod h1:2TUb0+EfkIj5fWhGy+oR3QiANCzHTWzkyNDEknxrQJI=
20122012
github.com/openshift/machine-api-provider-gcp v0.0.1-0.20231014045125-6096cc86f3ba h1:q9VMvYHgKq1v+3E57HIdbR9hJPNSmHDfZpOHsXC27Nk=
20132013
github.com/openshift/machine-api-provider-gcp v0.0.1-0.20231014045125-6096cc86f3ba/go.mod h1:G1BYMrC49dMOkCEjG+LPoe0rRXFRv8o/jqLuN4fgfGM=
20142014
github.com/openshift/machine-api-provider-ibmcloud v0.0.0-20231207164151-6b0b8ea7b16d h1:ELypg5zkw9jXCbp2jZ6iwYWTCtSqZVrxcKBQqwIgd2Y=

pkg/asset/installconfig/gcp/validation.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func Validate(client API, ic *types.InstallConfig) error {
7474
}
7575

7676
// ValidateInstanceType ensures the instance type has sufficient Vcpu and Memory.
77-
func ValidateInstanceType(client API, fieldPath *field.Path, project, region string, zones []string, instanceType string, req resourceRequirements, arch string) field.ErrorList {
77+
func ValidateInstanceType(client API, fieldPath *field.Path, project, region string, zones []string, diskType string, instanceType string, req resourceRequirements, arch string) field.ErrorList {
7878
allErrs := field.ErrorList{}
7979

8080
typeMeta, typeZones, err := client.GetMachineTypeWithZones(context.TODO(), project, region, instanceType)
@@ -85,6 +85,14 @@ func ValidateInstanceType(client API, fieldPath *field.Path, project, region str
8585
return append(allErrs, field.InternalError(nil, err))
8686
}
8787

88+
if diskType == "hyperdisk-balanced" {
89+
family, _, _ := strings.Cut(instanceType, "-")
90+
families := sets.NewString("c3", "c3d", "m1", "n4")
91+
if !families.Has(family) {
92+
allErrs = append(allErrs, field.NotSupported(fieldPath.Child("diskType"), family, families.List()))
93+
}
94+
}
95+
8896
userZones := sets.New(zones...)
8997
if len(userZones) == 0 {
9098
userZones = typeZones
@@ -153,6 +161,7 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList
153161
if ic.GCP.DefaultMachinePlatform != nil {
154162
defaultZones = ic.GCP.DefaultMachinePlatform.Zones
155163
defaultInstanceType = ic.GCP.DefaultMachinePlatform.InstanceType
164+
156165
if ic.GCP.DefaultMachinePlatform.InstanceType != "" {
157166
allErrs = append(allErrs,
158167
ValidateInstanceType(
@@ -161,6 +170,7 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList
161170
ic.GCP.ProjectID,
162171
ic.GCP.Region,
163172
ic.GCP.DefaultMachinePlatform.Zones,
173+
ic.GCP.DefaultMachinePlatform.DiskType,
164174
ic.GCP.DefaultMachinePlatform.InstanceType,
165175
defaultInstanceReq,
166176
unknownArchitecture,
@@ -192,6 +202,7 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList
192202
ic.GCP.ProjectID,
193203
ic.GCP.Region,
194204
zones,
205+
"", // the control plane nodes only support one disk type currently
195206
instanceType,
196207
controlPlaneReq,
197208
arch,
@@ -213,13 +224,20 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList
213224
zones = compute.Platform.GCP.Zones
214225
}
215226
}
227+
228+
diskType := ""
229+
if compute.Platform.GCP != nil && compute.Platform.GCP.DiskType != "" {
230+
diskType = compute.Platform.GCP.DiskType
231+
}
232+
216233
allErrs = append(allErrs,
217234
ValidateInstanceType(
218235
client,
219236
fieldPath.Child("platform", "gcp"),
220237
ic.GCP.ProjectID,
221238
ic.GCP.Region,
222239
zones,
240+
diskType,
223241
instanceType,
224242
computeReq,
225243
string(arch),

pkg/asset/installconfig/gcp/validation_test.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ var (
113113
"n2-standard-1": {GuestCpus: 1, MemoryMb: 8192},
114114
"n2-standard-2": {GuestCpus: 2, MemoryMb: 16384},
115115
"n2-standard-4": {GuestCpus: 4, MemoryMb: 32768},
116+
"n4-standard-4": {GuestCpus: 4, MemoryMb: 32768},
116117
"t2a-standard-4": {GuestCpus: 4, MemoryMb: 16384},
117118
}
118119

@@ -749,6 +750,7 @@ func TestValidateInstanceType(t *testing.T) {
749750
cases := []struct {
750751
name string
751752
zones []string
753+
diskType string
752754
instanceType string
753755
arch string
754756
expectedError bool
@@ -758,13 +760,15 @@ func TestValidateInstanceType(t *testing.T) {
758760
name: "Valid instance type with min requirements and no zones specified",
759761
zones: []string{},
760762
instanceType: "n1-standard-4",
763+
diskType: "pd-ssd",
761764
expectedError: false,
762765
expectedErrMsg: "",
763766
},
764767
{
765768
name: "Valid instance type with min requirements and valid zones specified",
766769
zones: []string{"a", "b"},
767770
instanceType: "n1-standard-4",
771+
diskType: "pd-ssd",
768772
arch: "amd64",
769773
expectedError: false,
770774
expectedErrMsg: "",
@@ -773,58 +777,82 @@ func TestValidateInstanceType(t *testing.T) {
773777
name: "Valid instance type with min requirements and invalid zones specified",
774778
zones: []string{"a", "b", "d", "x", "y"},
775779
instanceType: "n1-standard-4",
780+
diskType: "pd-ssd",
776781
expectedError: true,
777782
expectedErrMsg: `\[instance.type: Invalid value: "n1\-standard\-4": instance type not available in zones: \[x y\]\]$`,
778783
},
779784
{
780785
name: "Valid instance fails min requirements and no zones specified",
781786
zones: []string{},
782787
instanceType: "n1-standard-2",
788+
diskType: "pd-ssd",
783789
expectedError: true,
784790
expectedErrMsg: `^\[instance.type: Invalid value: "n1\-standard\-2": instance type does not meet minimum resource requirements of 4 vCPUs instance.type: Invalid value: "n1\-standard\-2": instance type does not meet minimum resource requirements of 15360 MB Memory\]$`,
785791
},
786792
{
787793
name: "Valid instance fails min requirements and valid zones specified",
788794
zones: []string{"a", "b"},
789795
instanceType: "n1-standard-1",
796+
diskType: "pd-ssd",
790797
expectedError: true,
791798
expectedErrMsg: ``,
792799
},
793800
{
794801
name: "Valid instance fails min requirements and invalid zones specified",
795802
zones: []string{"a", "x", "y"},
803+
diskType: "pd-ssd",
796804
expectedError: true,
797805
expectedErrMsg: ``,
798806
},
799807
{
800808
name: "Invalid instance and no zones specified",
801809
zones: []string{},
802810
instanceType: "invalid-instance-1",
811+
diskType: "pd-ssd",
803812
expectedError: true,
804813
expectedErrMsg: `^\[<nil>: Internal error: 404\]$`,
805814
},
806815
{
807816
name: "Invalid instance and valid zones specified",
808817
zones: []string{"a", "b"},
809818
instanceType: "invalid-instance-1",
819+
diskType: "pd-ssd",
810820
expectedError: true,
811821
expectedErrMsg: `^\[<nil>: Internal error: 404\]$`,
812822
},
813823
{
814824
name: "Invalid instance and invalid zones specified",
815825
zones: []string{"a", "x", "y", "z"},
816826
instanceType: "invalid-instance-1",
827+
diskType: "pd-ssd",
817828
expectedError: true,
818829
expectedErrMsg: `^\[<nil>: Internal error: 404\]$`,
819830
},
820831
{
821832
name: "Invalid instance architecture",
822833
zones: []string{"a", "b"},
823834
instanceType: "t2a-standard-4",
835+
diskType: "pd-ssd",
824836
arch: "amd64",
825837
expectedError: true,
826838
expectedErrMsg: `^\[instance.type: Invalid value: "t2a\-standard\-4": instance type architecture arm64 does not match specified architecture amd64\]$`,
827839
},
840+
{
841+
name: "Valid special instance type with min requirements",
842+
zones: []string{"a"},
843+
instanceType: "n4-standard-4",
844+
diskType: "hyperdisk-balanced",
845+
expectedError: false,
846+
expectedErrMsg: "",
847+
},
848+
{
849+
name: "Invalid special instance type with min requirements",
850+
zones: []string{"a"},
851+
instanceType: "n2-standard-4",
852+
diskType: "hyperdisk-balanced",
853+
expectedError: true,
854+
expectedErrMsg: `^\[instance.diskType: Unsupported value: \"n2\": supported values: \"c3\", \"c3d\", \"m1\", \"n4\"\]$`,
855+
},
828856
}
829857

830858
mockCtrl := gomock.NewController(t)
@@ -840,7 +868,7 @@ func TestValidateInstanceType(t *testing.T) {
840868

841869
for _, test := range cases {
842870
t.Run(test.name, func(t *testing.T) {
843-
errs := ValidateInstanceType(gcpClient, field.NewPath("instance"), "project-id", "region", test.zones, test.instanceType, controlPlaneReq, test.arch)
871+
errs := ValidateInstanceType(gcpClient, field.NewPath("instance"), "project-id", "region", test.zones, test.diskType, test.instanceType, controlPlaneReq, test.arch)
844872
if test.expectedError {
845873
assert.Regexp(t, test.expectedErrMsg, errs)
846874
} else {

pkg/destroy/gcp/gcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func getRegionFromZone(zoneName string) string {
241241
// projects/project/zones/zone/diskTypes/pd-standard -> "ssd_total_storage"
242242
func getDiskLimit(typeURL string) string {
243243
switch getNameFromURL("diskTypes", typeURL) {
244-
case "pd-balanced", "pd-ssd":
244+
case "pd-balanced", "pd-ssd", "hyperdisk-balanced":
245245
return "ssd_total_storage"
246246
case "pd-standard":
247247
return "disks_total_storage"

pkg/types/gcp/machinepools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type OSDisk struct {
8787
// DiskType defines the type of disk.
8888
// For control plane nodes, the valid value is pd-ssd.
8989
// +optional
90-
// +kubebuilder:validation:Enum=pd-balanced;pd-ssd;pd-standard
90+
// +kubebuilder:validation:Enum=pd-balanced;pd-ssd;pd-standard;hyperdisk-balanced
9191
DiskType string `json:"diskType"`
9292

9393
// DiskSizeGB defines the size of disk in GB.

pkg/types/gcp/validation/machinepool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ValidateMachinePool(platform *gcp.Platform, p *gcp.MachinePool, fldPath *fi
3030
}
3131

3232
if p.OSDisk.DiskType != "" {
33-
diskTypes := sets.NewString("pd-balanced", "pd-ssd", "pd-standard")
33+
diskTypes := sets.NewString("pd-balanced", "pd-ssd", "pd-standard", "hyperdisk-balanced")
3434
if !diskTypes.Has(p.OSDisk.DiskType) {
3535
allErrs = append(allErrs, field.NotSupported(fldPath.Child("diskType"), p.OSDisk.DiskType, diskTypes.List()))
3636
}

pkg/types/gcp/validation/machinepool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestValidateMachinePool(t *testing.T) {
4848
DiskType: "pd-",
4949
},
5050
},
51-
expected: `^test-path\.diskType: Unsupported value: "pd-": supported values: "pd-balanced", "pd-ssd", "pd-standard"$`,
51+
expected: `^test-path\.diskType: Unsupported value: "pd-": supported values: "hyperdisk-balanced", "pd-balanced", "pd-ssd", "pd-standard"$`,
5252
},
5353
{
5454
name: "valid disk size",

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers
11211121
github.com/openshift/library-go/pkg/config/clusterstatus
11221122
github.com/openshift/library-go/pkg/config/leaderelection
11231123
github.com/openshift/library-go/pkg/route/routeapihelpers
1124-
# github.com/openshift/machine-api-operator v0.2.1-0.20240702095949-e959540b5ab8
1124+
# github.com/openshift/machine-api-operator v0.2.1-0.20240722145313-3a817c78946a
11251125
## explicit; go 1.22.0
11261126
github.com/openshift/machine-api-operator/pkg/controller/machine
11271127
github.com/openshift/machine-api-operator/pkg/metrics

0 commit comments

Comments
 (0)