@@ -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,13 +841,19 @@ 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 :]
847
- cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
848
- if err != nil {
849
- return volumeLimitSmall , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
844
+ machineTypeSlice := strings .Split (machineType , "-" )
845
+ if len (machineTypeSlice ) > 2 {
846
+ cpuString := machineTypeSlice [2 ]
847
+ cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
848
+ if err != nil {
849
+ klog .Warningf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
850
+ return volumeLimitBig , nil
851
+ }
852
+ return common .MapNumber (cpus ), nil
853
+ } else {
854
+ klog .Warningf ("unconventional machine type: %v" , machineType )
855
+ return volumeLimitBig , nil
850
856
}
851
- return common .MapNumber (cpus ), nil
852
-
853
857
}
854
858
if strings .HasPrefix (machineType , "x4-" ) {
855
859
return x4HyperdiskLimit , nil
0 commit comments