Skip to content

Commit 16a57d4

Browse files
k8s-ci-robotsunnylovestiramisu
authored andcommitted
Merge pull request kubernetes-sigs#2092 from sunnylovestiramisu/attachLimit
Using Default PD Attach Limit for Gen3 Machines
1 parent 21128cc commit 16a57d4

File tree

3 files changed

+7
-106
lines changed

3 files changed

+7
-106
lines changed

pkg/common/utils_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,47 +2149,3 @@ func TestGetMinIopsThroughput(t *testing.T) {
21492149
})
21502150
}
21512151
}
2152-
2153-
func TestExtractCPUFromMachineType(t *testing.T) {
2154-
testcases := []struct {
2155-
name string
2156-
input string
2157-
expectOutput int64
2158-
expectErr bool
2159-
}{
2160-
{
2161-
name: "c3-highmem-176",
2162-
input: "c3-highmem-176",
2163-
expectOutput: 176,
2164-
},
2165-
{
2166-
name: "c3-standard-8-lssd",
2167-
input: "c3-standard-8-lssd",
2168-
expectOutput: 8,
2169-
},
2170-
{
2171-
name: "c3-standard-192-metal",
2172-
input: "c3-standard-192-metal",
2173-
expectOutput: 192,
2174-
},
2175-
{
2176-
name: "invalid input",
2177-
input: "something-not-valid",
2178-
expectOutput: 0,
2179-
expectErr: true,
2180-
},
2181-
}
2182-
2183-
for _, tc := range testcases {
2184-
t.Run(tc.name, func(t *testing.T) {
2185-
output, err := ExtractCPUFromMachineType(tc.input)
2186-
if output != tc.expectOutput {
2187-
t.Errorf("ExtractCPUFromMachineType: got %v, want %v", output, tc.expectOutput)
2188-
}
2189-
2190-
if gotErr := err != nil; gotErr != tc.expectErr {
2191-
t.Fatalf("ExtractCPUFromMachineType(%+v) = %v; expectedErr: %v", tc.input, err, tc.expectErr)
2192-
}
2193-
})
2194-
}
2195-
}

pkg/gce-pd-csi-driver/node.go

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,7 @@ const (
103103
// doc https://cloud.google.com/compute/docs/memory-optimized-machines#x4_disks
104104
x4HyperdiskLimit int64 = 39
105105
// doc https://cloud.google.com/compute/docs/accelerator-optimized-machines#a4-disks
106-
a4HyperdiskLimit int64 = 127
107-
// doc https://cloud.google.com/compute/docs/storage-optimized-machines#z3_disks
108-
// doc https://cloud.google.com/compute/docs/accelerator-optimized-machines#a3-disks
109-
gen3HyperdiskLimit int64 = 31
110-
// doc https://cloud.google.com/compute/docs/compute-optimized-machines#h3_disks
111-
h3HyperdiskLimit int64 = 7 // Use limit for Hyperdisk Balanced
106+
a4HyperdiskLimit int64 = 127
112107
defaultLinuxFsType = "ext4"
113108
defaultWindowsFsType = "ntfs"
114109
fsTypeExt3 = "ext3"
@@ -789,36 +784,6 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
789784
}
790785
}
791786

792-
// Process gen3 machine attach limits
793-
gen3MachineTypesPrefix := []string{"c3-", "c3d-"}
794-
for _, gen3Prefix := range gen3MachineTypesPrefix {
795-
if strings.HasPrefix(machineType, gen3Prefix) {
796-
cpus, err := common.ExtractCPUFromMachineType(machineType)
797-
if err != nil {
798-
return volumeLimitSmall, err
799-
}
800-
if cpus <= 8 || strings.Contains(machineType, "metal") {
801-
return volumeLimitSmall, nil
802-
}
803-
return gen3HyperdiskLimit, nil
804-
805-
}
806-
if strings.HasPrefix(machineType, "z3-") {
807-
return gen3HyperdiskLimit, nil
808-
}
809-
if strings.HasPrefix(machineType, "h3-") {
810-
return h3HyperdiskLimit, nil
811-
}
812-
if strings.HasPrefix(machineType, "a3-") {
813-
if machineType == "a3-ultragpu-8g" {
814-
return volumeLimitBig, nil
815-
} else {
816-
return gen3HyperdiskLimit, nil
817-
}
818-
}
819-
820-
}
821-
822787
return volumeLimitBig, nil
823788
}
824789

pkg/gce-pd-csi-driver/node_test.go

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -314,39 +314,19 @@ func TestNodeGetVolumeLimits(t *testing.T) {
314314
expVolumeLimit: a4HyperdiskLimit,
315315
},
316316
{
317-
name: "z3-highmem-176",
318-
machineType: "z3-highmem-176",
319-
expVolumeLimit: gen3HyperdiskLimit,
320-
},
321-
{
322-
name: "h3-standard-88",
323-
machineType: "h3-standard-88",
324-
expVolumeLimit: h3HyperdiskLimit,
325-
},
326-
{
327-
name: "a3-ultragpu-8g",
328-
machineType: "a3-ultragpu-8g",
317+
name: "c3-standard-4",
318+
machineType: "c3-standard-4",
329319
expVolumeLimit: volumeLimitBig,
330320
},
331-
{
332-
name: "a3-megagpu-8g",
333-
machineType: "a3-megagpu-8g",
334-
expVolumeLimit: gen3HyperdiskLimit, // 31
335-
},
336321
{
337322
name: "c3d-highmem-8-lssd",
338323
machineType: "c3d-highmem-8-lssd",
339-
expVolumeLimit: volumeLimitSmall, // 15
340-
},
341-
{
342-
name: "c3-standard-192-metal",
343-
machineType: "c3-standard-192-metal",
344-
expVolumeLimit: volumeLimitSmall, // 15
324+
expVolumeLimit: volumeLimitBig,
345325
},
346326
{
347-
name: "c3-standard-176",
348-
machineType: "c3-standard-176",
349-
expVolumeLimit: gen3HyperdiskLimit, // 31
327+
name: "c4a-standard-32-lssd",
328+
machineType: "c4a-standard-32-lssd",
329+
expVolumeLimit: 49,
350330
},
351331
}
352332

0 commit comments

Comments
 (0)