Skip to content

Commit

Permalink
Merge pull request #2733 from andyzhangx/resize-win2
Browse files Browse the repository at this point in the history
fix: resize is required after snapshot restore/volume clone on Windows
  • Loading branch information
andyzhangx authored Dec 14, 2024
2 parents 5fcba98 + 3147413 commit 4d7d7bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/azuredisk/azure_common_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func resizeVolume(devicePath, volumePath string, m *mount.SafeFormatAndMount) er

// needResizeVolume check whether device needs resize
func needResizeVolume(devicePath, volumePath string, m *mount.SafeFormatAndMount) (bool, error) {
return false, nil
return true, nil
}

// rescanVolume rescan device for detecting device size expansion
Expand Down
2 changes: 2 additions & 0 deletions pkg/azuredisk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ func (d *Driver) NodeStageVolume(_ context.Context, req *csi.NodeStageVolumeRequ
needResize = true
}
if !needResize {
// Filesystem resize is required after snapshot restore / volume clone
// https://github.com/kubernetes/kubernetes/issues/94929
if needResize, err = needResizeVolume(source, target, d.mounter); err != nil {
klog.Errorf("NodeStageVolume: could not determine if volume %s needs to be resized: %v", diskURI, err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/os/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ func ResizeVolume(volumeID string, size int64) error {
return fmt.Errorf("error getting the current size of volume (%s) with error (%v)", volumeID, err)
}

if currentSize >= finalSize {
// only resize if finalSize - currentSize is greater than 100MB
if finalSize-currentSize < 100*1024*1024 {
klog.V(2).Infof("Attempted to resize volume %s to a lower size, from currentBytes=%d wantedBytes=%d", volumeID, currentSize, finalSize)
return nil
}
Expand Down

0 comments on commit 4d7d7bb

Please sign in to comment.