@@ -573,7 +573,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
573
573
574
574
volumeLimits , err := ns .GetVolumeLimits ()
575
575
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
577
579
}
578
580
579
581
resp := & csi.NodeGetInfoResponse {
@@ -744,13 +746,17 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
744
746
gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
745
747
for _ , gen4Prefix := range gen4MachineTypesPrefix {
746
748
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 )
751
759
}
752
- return common .MapNumber (cpus ), nil
753
-
754
760
}
755
761
if strings .HasPrefix (machineType , "x4-" ) {
756
762
return x4HyperdiskLimit , nil
0 commit comments