From 3e5c37e327410335dc140e3d833118bdcc3d4c09 Mon Sep 17 00:00:00 2001 From: Jian Cheng Date: Sun, 8 Oct 2023 09:47:40 +0800 Subject: [PATCH] Changed the logic for comparing volsize and updatesize when scaling up. Signed-off-by: Esimest --- pkg/driver/controller.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index 0ce1c8b0..06bcf67d 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -553,20 +553,17 @@ func (cs *controller) ControllerExpandVolume( * to the specified volume ID is already larger than or equal to the target * capacity of the expansion request, the plugin should reply 0 OK. */ - if volsize >= updatedSize { - return csipayload.NewControllerExpandVolumeResponseBuilder(). - WithCapacityBytes(volsize). - Build(), nil - } - - if err := lvm.ResizeVolume(vol, updatedSize); err != nil { - return nil, status.Errorf( - codes.Internal, - "failed to handle ControllerExpandVolumeRequest for %s, {%s}", - volumeID, - err.Error(), - ) + if volsize < updatedSize { + if err := lvm.ResizeVolume(vol, updatedSize); err != nil { + return nil, status.Errorf( + codes.Internal, + "failed to handle ControllerExpandVolumeRequest for %s, {%s}", + volumeID, + err.Error(), + ) + } } + return csipayload.NewControllerExpandVolumeResponseBuilder(). WithCapacityBytes(updatedSize). WithNodeExpansionRequired(true).