Skip to content

Commit

Permalink
Add volume limits for m7i family
Browse files Browse the repository at this point in the history
Signed-off-by: Connor Catlett <conncatl@amazon.com>
  • Loading branch information
ConnorJC3 committed Aug 7, 2023
1 parent 993c417 commit ae24bc8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
21 changes: 21 additions & 0 deletions pkg/cloud/volume_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ func GetEBSLimitForInstanceType(it string) (int, bool) {
return 0, false
}

var dedicatedVolumeLimits = map[string]int{
"m7i.large": 32,
"m7i.xlarge": 32,
"m7i.2xlarge": 32,
"m7i.4xlarge": 32,
"m7i.8xlarge": 32,
"m7i.12xlarge": 32,
"m7i.16xlarge": 48,
"m7i.24xlarge": 64,
"m7i.48xlarge": 128,
}

func GetDedicatedLimitForInstanceType(it string) int {
limit, ok := dedicatedVolumeLimits[it]
if ok {
return limit
} else {
return 0
}
}

func GetNVMeInstanceStoreVolumesForInstanceType(it string) int {
if v, ok := nvmeInstanceStoreVolumes[it]; ok {
return v
Expand Down
8 changes: 6 additions & 2 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,13 @@ func (d *nodeService) getVolumesLimit() int64 {
isNitro := cloud.IsNitroInstanceType(instanceType)
availableAttachments := cloud.GetMaxAttachments(isNitro)
blockVolumes := d.metadata.GetNumBlockDeviceMappings()
dedicatedLimit := cloud.GetDedicatedLimitForInstanceType(instanceType)

// For Nitro instances, attachments are shared between EBS volumes, ENIs and NVMe instance stores
if isNitro {
// For special dedicated limit instance types, the limit is only for EBS volumes
// For (all other) Nitro instances, attachments are shared between EBS volumes, ENIs and NVMe instance stores
if dedicatedLimit != 0 {
availableAttachments = dedicatedLimit
} else if isNitro {
enis := d.metadata.GetNumAttachedENIs()
nvmeInstanceStoreVolumes := cloud.GetNVMeInstanceStoreVolumesForInstanceType(instanceType)
availableAttachments = availableAttachments - enis - nvmeInstanceStoreVolumes
Expand Down
13 changes: 12 additions & 1 deletion pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,17 @@ func TestNodeGetInfo(t *testing.T) {
expMaxVolumes: 0,
outpostArn: emptyOutpostArn,
},
{
name: "nitro instance with dedicated limit",
instanceID: "i-123456789abcdef01",
instanceType: "m7i.48xlarge",
availabilityZone: "us-west-2b",
region: "us-west-2",
volumeAttachLimit: -1,
attachedENIs: 2,
expMaxVolumes: 127, // 128 (max) - 1 (root)
outpostArn: emptyOutpostArn,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -2179,7 +2190,7 @@ func TestNodeGetInfo(t *testing.T) {
if tc.volumeAttachLimit < 0 {
mockMetadata.EXPECT().GetInstanceType().Return(tc.instanceType)
mockMetadata.EXPECT().GetNumBlockDeviceMappings().Return(tc.blockDevices)
if cloud.IsNitroInstanceType(tc.instanceType) {
if cloud.IsNitroInstanceType(tc.instanceType) && cloud.GetDedicatedLimitForInstanceType(tc.instanceType) == 0 {
mockMetadata.EXPECT().GetNumAttachedENIs().Return(tc.attachedENIs)
}
}
Expand Down

0 comments on commit ae24bc8

Please sign in to comment.