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

[cinder-csi-plugin] Resize raw block device #2694

Open
sergelogvinov opened this issue Oct 21, 2024 · 2 comments
Open

[cinder-csi-plugin] Resize raw block device #2694

sergelogvinov opened this issue Oct 21, 2024 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@sergelogvinov
Copy link
Contributor

/kind bug

What happened:

During the volume expansion process, there is a risk of accidentally resizing an unmanaged (raw) block device if it already has a file system on it. Since raw block devices are not tied to any file system by Kubernetes, operations like resizing can potentially corrupt the existing file system, as it is unaware of the underlying changes.

klog.V(4).Infof("NodeExpandVolume: called with args %+v", protosanitizer.StripSecrets(*req))
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
}
volumePath := req.GetVolumePath()
if len(volumePath) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume path not provided")
}
_, err := blockdevice.IsBlockDevice(volumePath)
if err != nil {
return nil, status.Errorf(codes.NotFound, "Failed to determine device path for volumePath %s: %v", volumePath, err)
}
output, err := ns.Mount.GetMountFs(volumePath)
if err != nil {
return nil, status.Errorf(codes.Internal, "Failed to find mount file system %s: %v", volumePath, err)
}
devicePath := strings.TrimSpace(string(output))
if devicePath == "" {
return nil, status.Error(codes.Internal, "Unable to find Device path for volume")
}
if ns.Opts.RescanOnResize {
// comparing current volume size with the expected one
newSize := req.GetCapacityRange().GetRequiredBytes()
if err := blockdevice.RescanBlockDeviceGeometry(devicePath, volumePath, newSize); err != nil {
return nil, status.Errorf(codes.Internal, "Could not verify %q volume size: %v", volumeID, err)
}
}
r := mountutil.NewResizeFs(ns.Mount.Mounter().Exec)
if _, err := r.Resize(devicePath, volumePath); err != nil {
return nil, status.Errorf(codes.Internal, "Could not resize volume %q: %v", volumeID, err)
}

What you expected to happen:

How to reproduce it:

Anything else we need to know?:

Environment:

  • csi plugin version: master branch
  • OpenStack version:
  • Others:
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 21, 2024
@sergelogvinov sergelogvinov changed the title [cinder-csi-plugin] Resize block device [cinder-csi-plugin] Resize raw block device Oct 21, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 19, 2025
@sergelogvinov
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants