Skip to content

Commit

Permalink
If availableAttachments <= 0 clamp value to 1
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Torres <[email protected]>
  • Loading branch information
torredil committed Dec 11, 2023
1 parent 80fbe37 commit c01d2fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ func (d *nodeService) getVolumesLimit() int64 {
availableAttachments = availableAttachments - enis - nvmeInstanceStoreVolumes
}
availableAttachments = availableAttachments - blockVolumes - 1 // -1 for root device
if availableAttachments < 0 {
availableAttachments = 0
if availableAttachments <= 0 {
availableAttachments = 1
}

maxEBSAttachments, ok := cloud.GetEBSLimitForInstanceType(instanceType)
Expand Down
6 changes: 3 additions & 3 deletions pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ func TestNodeGetInfo(t *testing.T) {
volumeAttachLimit: -1,
attachedENIs: 1,
blockDevices: 27,
expMaxVolumes: 0,
expMaxVolumes: 1,
outpostArn: emptyOutpostArn,
},
{
Expand All @@ -2170,7 +2170,7 @@ func TestNodeGetInfo(t *testing.T) {
volumeAttachLimit: -1,
attachedENIs: 1,
blockDevices: 39,
expMaxVolumes: 0,
expMaxVolumes: 1,
outpostArn: emptyOutpostArn,
},
{
Expand All @@ -2182,7 +2182,7 @@ func TestNodeGetInfo(t *testing.T) {
volumeAttachLimit: -1,
attachedENIs: 27,
blockDevices: 1,
expMaxVolumes: 0,
expMaxVolumes: 1,
outpostArn: emptyOutpostArn,
},
{
Expand Down

0 comments on commit c01d2fe

Please sign in to comment.