@@ -113,11 +113,13 @@ const (
113
113
// doc https://cloud.google.com/compute/docs/memory-optimized-machines#x4_disks
114
114
x4HyperdiskLimit int64 = 39
115
115
// 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"
121
123
122
124
readAheadKBMountFlagRegexPattern = "^read_ahead_kb=(.+)$"
123
125
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) {
847
849
}
848
850
}
849
851
850
- // Process gen4 machine attach limits
852
+ // Process gen4 machine attach limits which include vCPUs in the machine type
851
853
gen4MachineTypesPrefix := []string {"c4a-" , "c4-" , "n4-" , "c4d-" }
852
854
for _ , gen4Prefix := range gen4MachineTypesPrefix {
853
855
if strings .HasPrefix (machineType , gen4Prefix ) {
@@ -866,12 +868,32 @@ func (ns *GCENodeServer) GetVolumeLimits(ctx context.Context) (int64, error) {
866
868
}
867
869
}
868
870
}
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
+ }
869
888
if strings .HasPrefix (machineType , "x4-" ) {
870
889
return x4HyperdiskLimit , nil
871
890
}
872
891
if strings .HasPrefix (machineType , "a4-" ) {
873
892
return a4HyperdiskLimit , nil
874
893
}
894
+ if strings .HasPrefix (machineType , "c3-" ) && strings .HasSuffix (machineType , "-metal" ) {
895
+ return c3MetalHyperdiskLimit , nil
896
+ }
875
897
876
898
return volumeLimitBig , nil
877
899
}
0 commit comments