Skip to content

Commit 74549d5

Browse files
authored
Merge pull request #455 from davidz627/fix/newTypes
Update volume limits for new machine types: https://cloud.google.com/compute/docs/machine-types
2 parents d916699 + a9e5883 commit 74549d5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -505,16 +505,16 @@ func (ns *GCENodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpa
505505
}
506506

507507
func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
508-
var volumeLimits int64
509-
510508
// Machine-type format: n1-type-CPUS or custom-CPUS-RAM or f1/g1-type
511509
machineType := ns.MetadataService.GetMachineType()
512-
if strings.HasPrefix(machineType, "n1-") || strings.HasPrefix(machineType, "custom-") {
513-
volumeLimits = volumeLimitBig
514-
} else {
515-
volumeLimits = volumeLimitSmall
510+
511+
smallMachineTypes := []string{"f1-micro", "g1-small", "e2-micro", "e2-small", "e2-medium"}
512+
for _, st := range smallMachineTypes {
513+
if machineType == st {
514+
return volumeLimitSmall, nil
515+
}
516516
}
517-
return volumeLimits, nil
517+
return volumeLimitBig, nil
518518
}
519519

520520
func (ns *GCENodeServer) getDevicePath(volumeID string, partition string) (string, error) {

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

+5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ func TestNodeGetVolumeLimits(t *testing.T) {
165165
machineType: "custom-2-4096",
166166
expVolumeLimit: volumeLimitBig,
167167
},
168+
{
169+
name: "Predifined e2 machine",
170+
machineType: "e2-micro",
171+
expVolumeLimit: volumeLimitSmall,
172+
},
168173
}
169174

170175
for _, tc := range testCases {

0 commit comments

Comments
 (0)