From c01d2fe1921d6b153941df75c0784bcf38ef3435 Mon Sep 17 00:00:00 2001 From: Eddie Torres Date: Mon, 11 Dec 2023 19:22:44 +0000 Subject: [PATCH] If availableAttachments <= 0 clamp value to 1 Signed-off-by: Eddie Torres --- pkg/driver/node.go | 4 ++-- pkg/driver/node_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/driver/node.go b/pkg/driver/node.go index 68d9b84523..c2753e8b67 100644 --- a/pkg/driver/node.go +++ b/pkg/driver/node.go @@ -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) diff --git a/pkg/driver/node_test.go b/pkg/driver/node_test.go index a8be6083c2..397c931e48 100644 --- a/pkg/driver/node_test.go +++ b/pkg/driver/node_test.go @@ -2158,7 +2158,7 @@ func TestNodeGetInfo(t *testing.T) { volumeAttachLimit: -1, attachedENIs: 1, blockDevices: 27, - expMaxVolumes: 0, + expMaxVolumes: 1, outpostArn: emptyOutpostArn, }, { @@ -2170,7 +2170,7 @@ func TestNodeGetInfo(t *testing.T) { volumeAttachLimit: -1, attachedENIs: 1, blockDevices: 39, - expMaxVolumes: 0, + expMaxVolumes: 1, outpostArn: emptyOutpostArn, }, { @@ -2182,7 +2182,7 @@ func TestNodeGetInfo(t *testing.T) { volumeAttachLimit: -1, attachedENIs: 27, blockDevices: 1, - expMaxVolumes: 0, + expMaxVolumes: 1, outpostArn: emptyOutpostArn, }, {