@@ -575,7 +575,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
575
575
576
576
volumeLimits , err := ns .GetVolumeLimits (ctx )
577
577
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
579
581
}
580
582
581
583
resp := & csi.NodeGetInfoResponse {
@@ -762,13 +764,17 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
762
764
gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
763
765
for _ , gen4Prefix := range gen4MachineTypesPrefix {
764
766
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 )
769
777
}
770
- return common .MapNumber (cpus ), nil
771
-
772
778
}
773
779
if strings .HasPrefix (machineType , "x4-" ) {
774
780
return x4HyperdiskLimit , nil
0 commit comments