@@ -656,7 +656,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe
656
656
657
657
volumeLimits , err := ns .GetVolumeLimits (ctx )
658
658
if err != nil {
659
- klog .Errorf ("GetVolumeLimits failed: %v" , err .Error ())
659
+ klog .Errorf ("GetVolumeLimits failed: %v. The error is ignored so that the driver can register" , err .Error ())
660
+ // No error should be returned from NodeGetInfo, otherwise the driver will not register
661
+ err = nil
660
662
}
661
663
662
664
resp := & csi.NodeGetInfoResponse {
@@ -843,13 +845,17 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
843
845
gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" }
844
846
for _ , gen4Prefix := range gen4MachineTypesPrefix {
845
847
if strings .HasPrefix (machineType , gen4Prefix ) {
846
- cpuString := machineType [strings .LastIndex (machineType , "-" )+ 1 :]
847
- cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
848
- if err != nil {
849
- return volumeLimitSmall , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
848
+ machineTypeSlice := strings .Split (machineType , "-" )
849
+ if len (machineTypeSlice ) > 2 {
850
+ cpuString := machineTypeSlice [2 ]
851
+ cpus , err := strconv .ParseInt (cpuString , 10 , 64 )
852
+ if err != nil {
853
+ return volumeLimitBig , fmt .Errorf ("invalid cpuString %s for machine type: %v" , cpuString , machineType )
854
+ }
855
+ return common .MapNumber (cpus ), nil
856
+ } else {
857
+ return volumeLimitBig , fmt .Errorf ("unconventional machine type: %v" , machineType )
850
858
}
851
- return common .MapNumber (cpus ), nil
852
-
853
859
}
854
860
if strings .HasPrefix (machineType , "x4-" ) {
855
861
return x4HyperdiskLimit , nil
0 commit comments