mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update kubernetes to 1.28.0 in main
updating kubernetes to 1.28.0 in the main repo. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
b2fdc269c3
commit
ff3e84ad67
55
vendor/k8s.io/mount-utils/mount_helper_unix.go
generated
vendored
55
vendor/k8s.io/mount-utils/mount_helper_unix.go
generated
vendored
@ -20,14 +20,17 @@ limitations under the License.
|
||||
package mount
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"k8s.io/klog/v2"
|
||||
utilio "k8s.io/utils/io"
|
||||
)
|
||||
@ -91,7 +94,7 @@ type MountInfo struct { // nolint: golint
|
||||
|
||||
// ParseMountInfo parses /proc/xxx/mountinfo.
|
||||
func ParseMountInfo(filename string) ([]MountInfo, error) {
|
||||
content, err := utilio.ConsistentRead(filename, maxListTries)
|
||||
content, err := readMountInfo(filename)
|
||||
if err != nil {
|
||||
return []MountInfo{}, err
|
||||
}
|
||||
@ -173,8 +176,7 @@ func splitMountOptions(s string) []string {
|
||||
// isMountPointMatch returns true if the path in mp is the same as dir.
|
||||
// Handles case where mountpoint dir has been renamed due to stale NFS mount.
|
||||
func isMountPointMatch(mp MountPoint, dir string) bool {
|
||||
deletedDir := fmt.Sprintf("%s\\040(deleted)", dir)
|
||||
return ((mp.Path == dir) || (mp.Path == deletedDir))
|
||||
return strings.TrimSuffix(mp.Path, "\\040(deleted)") == dir
|
||||
}
|
||||
|
||||
// PathExists returns true if the specified path exists.
|
||||
@ -199,3 +201,50 @@ func PathExists(path string) (bool, error) {
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
// These variables are used solely by kernelHasMountinfoBug.
|
||||
var (
|
||||
hasMountinfoBug bool
|
||||
checkMountinfoBugOnce sync.Once
|
||||
)
|
||||
|
||||
// kernelHasMountinfoBug checks if the kernel bug that can lead to incomplete
|
||||
// mountinfo being read is fixed. It does so by checking the kernel version.
|
||||
//
|
||||
// The bug was fixed by the kernel commit 9f6c61f96f2d97 (since Linux 5.8).
|
||||
// Alas, there is no better way to check if the bug is fixed other than to
|
||||
// rely on the kernel version returned by uname.
|
||||
func kernelHasMountinfoBug() bool {
|
||||
checkMountinfoBugOnce.Do(func() {
|
||||
// Assume old kernel.
|
||||
hasMountinfoBug = true
|
||||
|
||||
uname := unix.Utsname{}
|
||||
err := unix.Uname(&uname)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
end := bytes.IndexByte(uname.Release[:], 0)
|
||||
v := bytes.SplitN(uname.Release[:end], []byte{'.'}, 3)
|
||||
if len(v) != 3 {
|
||||
return
|
||||
}
|
||||
major, _ := strconv.Atoi(string(v[0]))
|
||||
minor, _ := strconv.Atoi(string(v[1]))
|
||||
|
||||
if major > 5 || (major == 5 && minor >= 8) {
|
||||
hasMountinfoBug = false
|
||||
}
|
||||
})
|
||||
|
||||
return hasMountinfoBug
|
||||
}
|
||||
|
||||
func readMountInfo(path string) ([]byte, error) {
|
||||
if kernelHasMountinfoBug() {
|
||||
return utilio.ConsistentRead(path, maxListTries)
|
||||
}
|
||||
|
||||
return os.ReadFile(path)
|
||||
}
|
||||
|
9
vendor/k8s.io/mount-utils/mount_linux.go
generated
vendored
9
vendor/k8s.io/mount-utils/mount_linux.go
generated
vendored
@ -24,7 +24,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -37,7 +36,6 @@ import (
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
utilexec "k8s.io/utils/exec"
|
||||
utilio "k8s.io/utils/io"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -271,7 +269,7 @@ func detectSafeNotMountedBehavior() bool {
|
||||
// detectSafeNotMountedBehaviorWithExec is for testing with FakeExec.
|
||||
func detectSafeNotMountedBehaviorWithExec(exec utilexec.Interface) bool {
|
||||
// create a temp dir and try to umount it
|
||||
path, err := ioutil.TempDir("", "kubelet-detect-safe-umount")
|
||||
path, err := os.MkdirTemp("", "kubelet-detect-safe-umount")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Cannot create temp dir to detect safe 'not mounted' behavior: %v", err)
|
||||
return false
|
||||
@ -633,7 +631,7 @@ func (mounter *SafeFormatAndMount) GetDiskFormat(disk string) (string, error) {
|
||||
|
||||
// ListProcMounts is shared with NsEnterMounter
|
||||
func ListProcMounts(mountFilePath string) ([]MountPoint, error) {
|
||||
content, err := utilio.ConsistentRead(mountFilePath, maxListTries)
|
||||
content, err := readMountInfo(mountFilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -766,7 +764,7 @@ func (mounter *Mounter) IsMountPoint(file string) (bool, error) {
|
||||
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts.
|
||||
resolvedFile, err := filepath.EvalSymlinks(file)
|
||||
if err != nil {
|
||||
if errors.Is(isMntErr, fs.ErrNotExist) {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return false, fs.ErrNotExist
|
||||
}
|
||||
return false, err
|
||||
@ -810,7 +808,6 @@ func tryUnmount(target string, withSafeNotMountedBehavior bool, unmountTimeout t
|
||||
func forceUmount(target string, withSafeNotMountedBehavior bool) error {
|
||||
command := exec.Command("umount", "-f", target)
|
||||
output, err := command.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
return checkUmountError(target, command, output, err, withSafeNotMountedBehavior)
|
||||
}
|
||||
|
22
vendor/k8s.io/mount-utils/mount_windows.go
generated
vendored
22
vendor/k8s.io/mount-utils/mount_windows.go
generated
vendored
@ -82,11 +82,11 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
|
||||
|
||||
if source == "tmpfs" {
|
||||
klog.V(3).Infof("mounting source (%q), target (%q), with options (%q)", source, target, sanitizedOptionsForLogging)
|
||||
return os.MkdirAll(target, 0755)
|
||||
return os.MkdirAll(target, 0o755)
|
||||
}
|
||||
|
||||
parentDir := filepath.Dir(target)
|
||||
if err := os.MkdirAll(parentDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(parentDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -299,26 +299,20 @@ func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target
|
||||
}
|
||||
klog.V(4).Infof("diskMount: Disk successfully formatted, disk: %q, fstype: %q", source, fstype)
|
||||
|
||||
volumeIds, err := listVolumesOnDisk(source)
|
||||
volumeIds, err := ListVolumesOnDisk(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
driverPath := volumeIds[0]
|
||||
target = NormalizeWindowsPath(target)
|
||||
output, err := mounter.Exec.Command("cmd", "/c", "mklink", "/D", target, driverPath).CombinedOutput()
|
||||
if err != nil {
|
||||
klog.Errorf("mklink(%s, %s) failed: %v, output: %q", target, driverPath, err, string(output))
|
||||
return err
|
||||
}
|
||||
klog.V(2).Infof("formatAndMount disk(%s) fstype(%s) on(%s) with output(%s) successfully", driverPath, fstype, target, string(output))
|
||||
return nil
|
||||
return mounter.MountSensitive(driverPath, target, fstype, options, sensitiveOptions)
|
||||
}
|
||||
|
||||
// ListVolumesOnDisk - returns back list of volumes(volumeIDs) in the disk (requested in diskID).
|
||||
func listVolumesOnDisk(diskID string) (volumeIDs []string, err error) {
|
||||
cmd := fmt.Sprintf("(Get-Disk -DeviceId %s | Get-Partition | Get-Volume).UniqueId", diskID)
|
||||
func ListVolumesOnDisk(diskID string) (volumeIDs []string, err error) {
|
||||
// If a Disk has multiple volumes, Get-Volume may not return items in the same order.
|
||||
cmd := fmt.Sprintf("(Get-Disk -DeviceId %s | Get-Partition | Get-Volume | Sort-Object -Property UniqueId).UniqueId", diskID)
|
||||
output, err := exec.Command("powershell", "/c", cmd).CombinedOutput()
|
||||
klog.V(4).Infof("listVolumesOnDisk id from %s: %s", diskID, string(output))
|
||||
klog.V(4).Infof("ListVolumesOnDisk id from %s: %s", diskID, string(output))
|
||||
if err != nil {
|
||||
return []string{}, fmt.Errorf("error list volumes on disk. cmd: %s, output: %s, error: %v", cmd, string(output), err)
|
||||
}
|
||||
|
3
vendor/k8s.io/mount-utils/resizefs_linux.go
generated
vendored
3
vendor/k8s.io/mount-utils/resizefs_linux.go
generated
vendored
@ -45,7 +45,6 @@ func NewResizeFs(exec utilexec.Interface) *ResizeFs {
|
||||
// Resize perform resize of file system
|
||||
func (resizefs *ResizeFs) Resize(devicePath string, deviceMountPath string) (bool, error) {
|
||||
format, err := getDiskFormat(resizefs.exec, devicePath)
|
||||
|
||||
if err != nil {
|
||||
formatErr := fmt.Errorf("ResizeFS.Resize - error checking format for device %s: %v", devicePath, err)
|
||||
return false, formatErr
|
||||
@ -78,7 +77,6 @@ func (resizefs *ResizeFs) extResize(devicePath string) (bool, error) {
|
||||
|
||||
resizeError := fmt.Errorf("resize of device %s failed: %v. resize2fs output: %s", devicePath, err, string(output))
|
||||
return false, resizeError
|
||||
|
||||
}
|
||||
|
||||
func (resizefs *ResizeFs) xfsResize(deviceMountPath string) (bool, error) {
|
||||
@ -161,6 +159,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()
|
||||
outStr := strings.TrimSpace(string(output))
|
||||
|
Reference in New Issue
Block a user