diff --git a/pkg/azuredisk/nodeserver.go b/pkg/azuredisk/nodeserver.go index 10082b035f..49949024ce 100644 --- a/pkg/azuredisk/nodeserver.go +++ b/pkg/azuredisk/nodeserver.go @@ -481,8 +481,10 @@ func (d *Driver) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolume } } + var retErr error if err := resizeVolume(devicePath, volumePath, d.mounter); err != nil { - return nil, status.Errorf(codes.Internal, "could not resize volume %q (%q): %v", volumeID, devicePath, err) + retErr = status.Errorf(codes.Internal, "could not resize volume %q (%q): %v", volumeID, devicePath, err) + klog.Errorf("%v, will continue checking whether the volume has been resized", retErr) } gotBlockSizeBytes, err := getBlockSizeBytes(devicePath, d.mounter) @@ -491,9 +493,13 @@ func (d *Driver) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolume } gotBlockGiB := volumehelper.RoundUpGiB(gotBlockSizeBytes) if gotBlockGiB < requestGiB { + if retErr != nil { + return nil, retErr + } // Because size was rounded up, getting more size than requested will be a success. return nil, status.Errorf(codes.Internal, "resize requested for %v, but after resizing volume size was %v", requestGiB, gotBlockGiB) } + klog.V(2).Infof("NodeExpandVolume succeeded on resizing volume %v to %v", volumeID, gotBlockSizeBytes) return &csi.NodeExpandVolumeResponse{ diff --git a/pkg/azuredisk/nodeserver_test.go b/pkg/azuredisk/nodeserver_test.go index 808ba33620..4ab5c7937d 100644 --- a/pkg/azuredisk/nodeserver_test.go +++ b/pkg/azuredisk/nodeserver_test.go @@ -1140,7 +1140,7 @@ func TestNodeExpandVolume(t *testing.T) { }, expectedErr: resizeErr, skipOnDarwin: true, // ResizeFs not supported on Darwin - outputScripts: []testingexec.FakeAction{findmntAction, blkidAction, resize2fsFailedAction}, + outputScripts: []testingexec.FakeAction{findmntAction, blkidAction, resize2fsFailedAction, blockdevSizeTooSmallAction}, }, { desc: "Resize too small failure", diff --git a/pkg/azuredisk/nodeserver_v2.go b/pkg/azuredisk/nodeserver_v2.go index 7951fae858..bc9a375e6d 100644 --- a/pkg/azuredisk/nodeserver_v2.go +++ b/pkg/azuredisk/nodeserver_v2.go @@ -466,8 +466,10 @@ func (d *DriverV2) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolu } } + var retErr error if err := resizeVolume(devicePath, volumePath, d.mounter); err != nil { - return nil, status.Errorf(codes.Internal, "could not resize volume %q (%q): %v", volumeID, devicePath, err) + retErr = status.Errorf(codes.Internal, "could not resize volume %q (%q): %v", volumeID, devicePath, err) + klog.Errorf("%v, will continue checking whether the volume has been resized", retErr) } gotBlockSizeBytes, err := getBlockSizeBytes(devicePath, d.mounter) @@ -476,6 +478,9 @@ func (d *DriverV2) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolu } gotBlockGiB := volumehelper.RoundUpGiB(gotBlockSizeBytes) if gotBlockGiB < requestGiB { + if retErr != nil { + return nil, retErr + } // Because size was rounded up, getting more size than requested will be a success. return nil, status.Errorf(codes.Internal, "resize requested for %v, but after resizing volume size was %v", requestGiB, gotBlockGiB) }