@@ -113,11 +113,13 @@ const (
113113 // doc https://cloud.google.com/compute/docs/memory-optimized-machines#x4_disks
114114 x4HyperdiskLimit int64 = 39
115115 // doc https://cloud.google.com/compute/docs/accelerator-optimized-machines#a4-disks
116- a4HyperdiskLimit int64 = 127
117- defaultLinuxFsType = "ext4"
118- defaultWindowsFsType = "ntfs"
119- fsTypeExt3 = "ext3"
120- fsTypeBtrfs = "btrfs"
116+ a4HyperdiskLimit int64 = 127
117+ a4xMetalHyperdiskLimit int64 = 31
118+ c3MetalHyperdiskLimit int64 = 15
119+ defaultLinuxFsType = "ext4"
120+ defaultWindowsFsType = "ntfs"
121+ fsTypeExt3 = "ext3"
122+ fsTypeBtrfs = "btrfs"
121123
122124 readAheadKBMountFlagRegexPattern = "^read_ahead_kb=(.+)$"
123125 btrfsReclaimDataRegexPattern = "^btrfs-allocation-data-bg_reclaim_threshold=(\\ d{1,2})$" // 0-99 are valid, incl. 00
@@ -847,7 +849,7 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
847849 }
848850 }
849851
850- // Process gen4 machine attach limits
852+ // Process gen4 machine attach limits which include vCPUs in the machine type
851853 gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" , "c4d-" }
852854 for _ , gen4Prefix := range gen4MachineTypesPrefix {
853855 if strings .HasPrefix (machineType , gen4Prefix ) {
@@ -866,12 +868,32 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
866868 }
867869 }
868870 }
871+ // Process gen4 A4X machine attach limits, which have a -1g/-2g/-4g/metal suffix
872+ if strings .HasPrefix (machineType , "a4x-" ) {
873+ machineTypeSlice := strings .Split (machineType , "-" )
874+ if len (machineTypeSlice ) < 3 {
875+ return volumeLimitBig , fmt .Errorf ("unconventional machine type: %v" , machineType )
876+ }
877+ gpuString := machineTypeSlice [2 ]
878+ if gpuString == "metal" {
879+ return a4xMetalHyperdiskLimit , nil
880+ }
881+ gpuString = gpuString [0 : len (gpuString )- 1 ] // Remove the 'g' suffix
882+ gpus , err := strconv .ParseInt (gpuString , 10 , 64 )
883+ if err != nil {
884+ return volumeLimitBig , fmt .Errorf ("invalid gpuString %s for machine type: %v" , gpuString , machineType )
885+ }
886+ return common .GetHyperdiskAttachLimit ("a4x" , gpus ), nil
887+ }
869888 if strings .HasPrefix (machineType , "x4-" ) {
870889 return x4HyperdiskLimit , nil
871890 }
872891 if strings .HasPrefix (machineType , "a4-" ) {
873892 return a4HyperdiskLimit , nil
874893 }
894+ if strings .HasPrefix (machineType , "c3-" ) && strings .HasSuffix (machineType , "-metal" ) {
895+ return c3MetalHyperdiskLimit , nil
896+ }
875897
876898 return volumeLimitBig , nil
877899}
0 commit comments