@@ -507,7 +507,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
507507
508508 volumeLimits , err := ns .GetVolumeLimits ()
509509 if err != nil {
510- klog .Errorf ("GetVolumeLimits failed: %v" , err .Error ())
510+ klog .Errorf ("GetVolumeLimits failed: %v. The error is ignored so that the driver can register" , err .Error ())
511+ // No error should be returned from NodeGetInfo, otherwise the driver will not register
512+ err = nil
511513 }
512514
513515 resp := & csi.NodeGetInfoResponse {
@@ -678,13 +680,17 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
678680 gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
679681 for _ , gen4Prefix := range gen4MachineTypesPrefix {
680682 if strings .HasPrefix (machineType , gen4Prefix ) {
681- cpuString := machineType [strings .LastIndex (machineType , "-" )+ 1 :]
682- cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
683- if err != nil {
684- return volumeLimitSmall , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
683+ machineTypeSlice := strings .Split (machineType , "-" )
684+ if len (machineTypeSlice ) > 2 {
685+ cpuString := machineTypeSlice [2 ]
686+ cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
687+ if err != nil {
688+ return volumeLimitBig , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
689+ }
690+ return common .MapNumber (cpus ), nil
691+ } else {
692+ return volumeLimitBig , fmt .Errorf ("unconventional machine type: %v" , machineType )
685693 }
686- return common .MapNumber (cpus ), nil
687-
688694 }
689695 if strings .HasPrefix (machineType , "x4-" ) {
690696 return x4HyperdiskLimit , nil
0 commit comments