mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update all k8s packages to 0.27.2
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
07b05616a0
commit
2551a0b05f
33
vendor/k8s.io/mount-utils/resizefs_linux.go
generated
vendored
33
vendor/k8s.io/mount-utils/resizefs_linux.go
generated
vendored
@ -28,6 +28,10 @@ import (
|
||||
utilexec "k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
const (
|
||||
blockDev = "blockdev"
|
||||
)
|
||||
|
||||
// ResizeFs Provides support for resizing file systems
|
||||
type ResizeFs struct {
|
||||
exec utilexec.Interface
|
||||
@ -104,6 +108,17 @@ func (resizefs *ResizeFs) btrfsResize(deviceMountPath string) (bool, error) {
|
||||
}
|
||||
|
||||
func (resizefs *ResizeFs) NeedResize(devicePath string, deviceMountPath string) (bool, error) {
|
||||
// Do nothing if device is mounted as readonly
|
||||
readonly, err := resizefs.getDeviceRO(devicePath)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if readonly {
|
||||
klog.V(3).Infof("ResizeFs.needResize - no resize possible since filesystem %s is readonly", devicePath)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
deviceSize, err := resizefs.getDeviceSize(devicePath)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -147,7 +162,7 @@ func (resizefs *ResizeFs) NeedResize(devicePath string, deviceMountPath string)
|
||||
return true, nil
|
||||
}
|
||||
func (resizefs *ResizeFs) getDeviceSize(devicePath string) (uint64, error) {
|
||||
output, err := resizefs.exec.Command("blockdev", "--getsize64", devicePath).CombinedOutput()
|
||||
output, err := resizefs.exec.Command(blockDev, "--getsize64", devicePath).CombinedOutput()
|
||||
outStr := strings.TrimSpace(string(output))
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to read size of device %s: %s: %s", devicePath, err, outStr)
|
||||
@ -159,6 +174,22 @@ func (resizefs *ResizeFs) getDeviceSize(devicePath string) (uint64, error) {
|
||||
return size, nil
|
||||
}
|
||||
|
||||
func (resizefs *ResizeFs) getDeviceRO(devicePath string) (bool, error) {
|
||||
output, err := resizefs.exec.Command(blockDev, "--getro", devicePath).CombinedOutput()
|
||||
outStr := strings.TrimSpace(string(output))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get readonly bit from device %s: %s: %s", devicePath, err, outStr)
|
||||
}
|
||||
switch outStr {
|
||||
case "0":
|
||||
return false, nil
|
||||
case "1":
|
||||
return true, nil
|
||||
default:
|
||||
return false, fmt.Errorf("Failed readonly device check. Expected 1 or 0, got '%s'", outStr)
|
||||
}
|
||||
}
|
||||
|
||||
func (resizefs *ResizeFs) getExtSize(devicePath string) (uint64, uint64, error) {
|
||||
output, err := resizefs.exec.Command("dumpe2fs", "-h", devicePath).CombinedOutput()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user