@@ -575,7 +575,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
575575
576576 volumeLimits , err := ns .GetVolumeLimits (ctx )
577577 if err != nil {
578- klog .Errorf ("GetVolumeLimits failed: %v" , err .Error ())
578+ klog .Errorf ("GetVolumeLimits failed: %v. The error is ignored so that the driver can register" , err .Error ())
579+ // No error should be returned from NodeGetInfo, otherwise the driver will not register
580+ err = nil
579581 }
580582
581583 resp := & csi.NodeGetInfoResponse {
@@ -762,13 +764,17 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
762764 gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
763765 for _ , gen4Prefix := range gen4MachineTypesPrefix {
764766 if strings .HasPrefix (machineType , gen4Prefix ) {
765- cpuString := machineType [strings .LastIndex (machineType , "-" )+ 1 :]
766- cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
767- if err != nil {
768- return volumeLimitSmall , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
767+ machineTypeSlice := strings .Split (machineType , "-" )
768+ if len (machineTypeSlice ) > 2 {
769+ cpuString := machineTypeSlice [2 ]
770+ cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
771+ if err != nil {
772+ return volumeLimitBig , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
773+ }
774+ return common .MapNumber (cpus ), nil
775+ } else {
776+ return volumeLimitBig , fmt .Errorf ("unconventional machine type: %v" , machineType )
769777 }
770- return common .MapNumber (cpus ), nil
771-
772778 }
773779 if strings .HasPrefix (machineType , "x4-" ) {
774780 return x4HyperdiskLimit , nil
0 commit comments