@@ -573,7 +573,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
573573
574574 volumeLimits , err := ns .GetVolumeLimits ()
575575 if err != nil {
576- klog .Errorf ("GetVolumeLimits failed: %v" , err .Error ())
576+ klog .Errorf ("GetVolumeLimits failed: %v. The error is ignored so that the driver can register" , err .Error ())
577+ // No error should be returned from NodeGetInfo, otherwise the driver will not register
578+ err = nil
577579 }
578580
579581 resp := & csi.NodeGetInfoResponse {
@@ -744,13 +746,17 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
744746 gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
745747 for _ , gen4Prefix := range gen4MachineTypesPrefix {
746748 if strings .HasPrefix (machineType , gen4Prefix ) {
747- cpuString := machineType [strings .LastIndex (machineType , "-" )+ 1 :]
748- cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
749- if err != nil {
750- return volumeLimitSmall , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
749+ machineTypeSlice := strings .Split (machineType , "-" )
750+ if len (machineTypeSlice ) > 2 {
751+ cpuString := machineTypeSlice [2 ]
752+ cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
753+ if err != nil {
754+ return volumeLimitBig , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
755+ }
756+ return common .MapNumber (cpus ), nil
757+ } else {
758+ return volumeLimitBig , fmt .Errorf ("unconventional machine type: %v" , machineType )
751759 }
752- return common .MapNumber (cpus ), nil
753-
754760 }
755761 if strings .HasPrefix (machineType , "x4-" ) {
756762 return x4HyperdiskLimit , nil
0 commit comments