diff --git a/pkg/common/utils.go b/pkg/common/utils.go index 81ba65f05..b15181b34 100644 --- a/pkg/common/utils.go +++ b/pkg/common/utils.go @@ -24,7 +24,6 @@ import ( "net/http" "regexp" "slices" - "strconv" "strings" "time" @@ -773,25 +772,6 @@ func MapNumber(num int64) int64 { return 0 } -func ExtractCPUFromMachineType(input string) (int64, error) { - // Regex to find the number at the end of the string, - // it allows optional -lssd suffix. - re := regexp.MustCompile(`(\d+)(?:-lssd|-metal)?$`) - - match := re.FindStringSubmatch(input) - if len(match) < 2 { - return 0, fmt.Errorf("no number found at the end of the input string: %s", input) - } - - numberStr := match[1] - number, err := strconv.ParseInt(numberStr, 10, 64) - if err != nil { - return 0, fmt.Errorf("failed to convert string '%s' to integer: %w", numberStr, err) - } - - return number, nil -} - func DiskTypeLabelKey(diskType string) string { return fmt.Sprintf("%s/%s", DiskTypeKeyPrefix, diskType) } diff --git a/pkg/common/utils_test.go b/pkg/common/utils_test.go index 71bf0a777..1d4cef0e3 100644 --- a/pkg/common/utils_test.go +++ b/pkg/common/utils_test.go @@ -2149,47 +2149,3 @@ func TestGetMinIopsThroughput(t *testing.T) { }) } } - -func TestExtractCPUFromMachineType(t *testing.T) { - testcases := []struct { - name string - input string - expectOutput int64 - expectErr bool - }{ - { - name: "c3-highmem-176", - input: "c3-highmem-176", - expectOutput: 176, - }, - { - name: "c3-standard-8-lssd", - input: "c3-standard-8-lssd", - expectOutput: 8, - }, - { - name: "c3-standard-192-metal", - input: "c3-standard-192-metal", - expectOutput: 192, - }, - { - name: "invalid input", - input: "something-not-valid", - expectOutput: 0, - expectErr: true, - }, - } - - for _, tc := range testcases { - t.Run(tc.name, func(t *testing.T) { - output, err := ExtractCPUFromMachineType(tc.input) - if output != tc.expectOutput { - t.Errorf("ExtractCPUFromMachineType: got %v, want %v", output, tc.expectOutput) - } - - if gotErr := err != nil; gotErr != tc.expectErr { - t.Fatalf("ExtractCPUFromMachineType(%+v) = %v; expectedErr: %v", tc.input, err, tc.expectErr) - } - }) - } -} diff --git a/pkg/gce-pd-csi-driver/node.go b/pkg/gce-pd-csi-driver/node.go index 54950b481..959eef2a4 100644 --- a/pkg/gce-pd-csi-driver/node.go +++ b/pkg/gce-pd-csi-driver/node.go @@ -103,12 +103,7 @@ const ( // doc https://cloud.google.com/compute/docs/memory-optimized-machines#x4_disks x4HyperdiskLimit int64 = 39 // doc https://cloud.google.com/compute/docs/accelerator-optimized-machines#a4-disks - a4HyperdiskLimit int64 = 127 - // doc https://cloud.google.com/compute/docs/storage-optimized-machines#z3_disks - // doc https://cloud.google.com/compute/docs/accelerator-optimized-machines#a3-disks - gen3HyperdiskLimit int64 = 31 - // doc https://cloud.google.com/compute/docs/compute-optimized-machines#h3_disks - h3HyperdiskLimit int64 = 7 // Use limit for Hyperdisk Balanced + a4HyperdiskLimit int64 = 127 defaultLinuxFsType = "ext4" defaultWindowsFsType = "ntfs" fsTypeExt3 = "ext3" @@ -783,36 +778,6 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) { } } - // Process gen3 machine attach limits - gen3MachineTypesPrefix := []string{"c3-", "c3d-"} - for _, gen3Prefix := range gen3MachineTypesPrefix { - if strings.HasPrefix(machineType, gen3Prefix) { - cpus, err := common.ExtractCPUFromMachineType(machineType) - if err != nil { - return volumeLimitSmall, err - } - if cpus <= 8 || strings.Contains(machineType, "metal") { - return volumeLimitSmall, nil - } - return gen3HyperdiskLimit, nil - - } - if strings.HasPrefix(machineType, "z3-") { - return gen3HyperdiskLimit, nil - } - if strings.HasPrefix(machineType, "h3-") { - return h3HyperdiskLimit, nil - } - if strings.HasPrefix(machineType, "a3-") { - if machineType == "a3-ultragpu-8g" { - return volumeLimitBig, nil - } else { - return gen3HyperdiskLimit, nil - } - } - - } - return volumeLimitBig, nil } diff --git a/pkg/gce-pd-csi-driver/node_test.go b/pkg/gce-pd-csi-driver/node_test.go index f4ada1d87..4b004f7db 100644 --- a/pkg/gce-pd-csi-driver/node_test.go +++ b/pkg/gce-pd-csi-driver/node_test.go @@ -310,39 +310,14 @@ func TestNodeGetVolumeLimits(t *testing.T) { expVolumeLimit: a4HyperdiskLimit, }, { - name: "z3-highmem-176", - machineType: "z3-highmem-176", - expVolumeLimit: gen3HyperdiskLimit, - }, - { - name: "h3-standard-88", - machineType: "h3-standard-88", - expVolumeLimit: h3HyperdiskLimit, - }, - { - name: "a3-ultragpu-8g", - machineType: "a3-ultragpu-8g", + name: "c3-standard-4", + machineType: "c3-standard-4", expVolumeLimit: volumeLimitBig, }, - { - name: "a3-megagpu-8g", - machineType: "a3-megagpu-8g", - expVolumeLimit: gen3HyperdiskLimit, // 31 - }, { name: "c3d-highmem-8-lssd", machineType: "c3d-highmem-8-lssd", - expVolumeLimit: volumeLimitSmall, // 15 - }, - { - name: "c3-standard-192-metal", - machineType: "c3-standard-192-metal", - expVolumeLimit: volumeLimitSmall, // 15 - }, - { - name: "c3-standard-176", - machineType: "c3-standard-176", - expVolumeLimit: gen3HyperdiskLimit, // 31 + expVolumeLimit: volumeLimitBig, }, }