@@ -654,10 +654,8 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
654
654
655
655
nodeID := common .CreateNodeID (ns .MetadataService .GetProject (), ns .MetadataService .GetZone (), ns .MetadataService .GetName ())
656
656
657
+ // err is always nil
657
658
volumeLimits , err := ns .GetVolumeLimits (ctx )
658
- if err != nil {
659
- klog .Errorf ("GetVolumeLimits failed: %v" , err .Error ())
660
- }
661
659
662
660
resp := & csi.NodeGetInfoResponse {
663
661
NodeId : nodeID ,
@@ -843,10 +841,12 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
843
841
gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
844
842
for _ , gen4Prefix := range gen4MachineTypesPrefix {
845
843
if strings .HasPrefix (machineType , gen4Prefix ) {
846
- cpuString := machineType [strings .LastIndex (machineType , "-" )+ 1 :]
844
+ machineTypeSlice := strings .Split (machineType , "-" )
845
+ cpuString := machineTypeSlice [2 ]
847
846
cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
848
847
if err != nil {
849
- return volumeLimitSmall , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
848
+ klog .Warningf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
849
+ return volumeLimitSmall , nil
850
850
}
851
851
return common .MapNumber (cpus ), nil
852
852
0 commit comments