Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: second expand volume failure on Ubuntu 22.04 #1728

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/azuredisk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/azuredisk/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion pkg/azuredisk/nodeserver_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down