From 3f02221fe7cd8e9244cd30a1f2a51d4104e39580 Mon Sep 17 00:00:00 2001 From: Eddie Torres Date: Thu, 9 Nov 2023 04:06:33 +0000 Subject: [PATCH] Do not return an error if volume is optimizing in validateModifyVolume Signed-off-by: Eddie Torres --- pkg/cloud/cloud.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/cloud/cloud.go b/pkg/cloud/cloud.go index 56905f587..084e1390a 100644 --- a/pkg/cloud/cloud.go +++ b/pkg/cloud/cloud.go @@ -1283,9 +1283,10 @@ func (c *cloud) validateModifyVolume(ctx context.Context, volumeID string, newSi return true, oldSizeGiB, fmt.Errorf("error fetching volume modifications for %q: %w", volumeID, err) } + state := "" // latestMod can be nil if the volume has never been modified if latestMod != nil { - state := aws.StringValue(latestMod.ModificationState) + state = aws.StringValue(latestMod.ModificationState) if state == ec2.VolumeModificationStateModifying { // If volume is already modifying, detour to waiting for it to modify klog.V(5).InfoS("[Debug] Watching ongoing modification", "volumeID", volumeID) @@ -1295,8 +1296,6 @@ func (c *cloud) validateModifyVolume(ctx context.Context, volumeID string, newSi } returnGiB, returnErr := c.checkDesiredState(ctx, volumeID, newSizeGiB, options) return false, returnGiB, returnErr - } else if state == ec2.VolumeModificationStateOptimizing { - return true, 0, fmt.Errorf("volume %q in OPTIMIZING state, cannot currently modify", volumeID) } } @@ -1314,6 +1313,10 @@ func (c *cloud) validateModifyVolume(ctx context.Context, volumeID string, newSi return false, returnGiB, returnErr } + if state == ec2.VolumeModificationStateOptimizing { + return true, 0, fmt.Errorf("volume %q in OPTIMIZING state, cannot currently modify", volumeID) + } + return true, 0, nil }