Skip to content

Commit

Permalink
Do not return an error if volume is optimizing in validateModifyVolume
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Torres <torredil@amazon.com>
  • Loading branch information
torredil committed Nov 9, 2023
1 parent d071db8 commit 3f02221
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}

Expand All @@ -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
}

Expand Down

0 comments on commit 3f02221

Please sign in to comment.