@@ -507,7 +507,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
507
507
508
508
volumeLimits , err := ns .GetVolumeLimits ()
509
509
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
511
513
}
512
514
513
515
resp := & csi.NodeGetInfoResponse {
@@ -678,13 +680,17 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
678
680
gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
679
681
for _ , gen4Prefix := range gen4MachineTypesPrefix {
680
682
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 )
685
693
}
686
- return common .MapNumber (cpus ), nil
687
-
688
694
}
689
695
if strings .HasPrefix (machineType , "x4-" ) {
690
696
return x4HyperdiskLimit , nil
0 commit comments