From a8e9d66009b0c364279507e1a90ea9e2391174ed Mon Sep 17 00:00:00 2001 From: Praveen M Date: Wed, 22 May 2024 17:39:00 +0530 Subject: [PATCH] build: replace k8s.io/mount-utils to v0.29.3 Signed-off-by: Praveen M --- go.mod | 4 +- go.sum | 4 +- vendor/k8s.io/mount-utils/mount_linux.go | 73 +++------------------- vendor/k8s.io/mount-utils/mount_windows.go | 6 +- vendor/modules.txt | 6 +- 5 files changed, 19 insertions(+), 74 deletions(-) diff --git a/go.mod b/go.mod index 6294e53bd..ba90eb348 100644 --- a/go.mod +++ b/go.mod @@ -223,7 +223,9 @@ replace ( k8s.io/kubelet => k8s.io/kubelet v0.30.0 k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.0 k8s.io/metrics => k8s.io/metrics v0.30.0 - k8s.io/mount-utils => k8s.io/mount-utils v0.30.0 + + // TODO: replace with latest once https://github.com/ceph/ceph-csi/issues/4633 is fixed + k8s.io/mount-utils => k8s.io/mount-utils v0.29.3 k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.30.0 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.30.0 // layeh.com seems to be misbehaving diff --git a/go.sum b/go.sum index 4cd351685..b60f0b2d7 100644 --- a/go.sum +++ b/go.sum @@ -2649,8 +2649,8 @@ k8s.io/kubelet v0.30.0 h1:/pqHVR2Rn8ExCpn211wL3pMtqRFpcBcJPl4+1INbIMk= k8s.io/kubelet v0.30.0/go.mod h1:WukdKqbQxnj+csn3K8XOKeX7Sh60J/da25IILjvvB5s= k8s.io/kubernetes v1.30.0 h1:u3Yw8rNlo2NDSGaDpoxoHXLPQnEu1tfqHATKOJe94HY= k8s.io/kubernetes v1.30.0/go.mod h1:yPbIk3MhmhGigX62FLJm+CphNtjxqCvAIFQXup6RKS0= -k8s.io/mount-utils v0.30.0 h1:EceYTNYVabfpdtIAHC4KgMzoZkm1B8ovZ1J666mYZQI= -k8s.io/mount-utils v0.30.0/go.mod h1:9sCVmwGLcV1MPvbZ+rToMDnl1QcGozy+jBPd0MsQLIo= +k8s.io/mount-utils v0.29.3 h1:iEcqPP7Vv8UClH8nnMfovtmy/04fIloRW9JuSXykoZ0= +k8s.io/mount-utils v0.29.3/go.mod h1:9IWJTMe8tG0MYMLEp60xK9GYVeCdA3g4LowmnVi+t9Y= k8s.io/pod-security-admission v0.30.0 h1:C8J/zbrA3hVR7jatN+mN/ymUWxwU6KceS5HsEEt6rTY= k8s.io/pod-security-admission v0.30.0/go.mod h1:eyzZB+gtMwnNduqr9tVO2vjf2DdepZsUA11SzyfXhfM= k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= diff --git a/vendor/k8s.io/mount-utils/mount_linux.go b/vendor/k8s.io/mount-utils/mount_linux.go index 07ce76de1..7d1807230 100644 --- a/vendor/k8s.io/mount-utils/mount_linux.go +++ b/vendor/k8s.io/mount-utils/mount_linux.go @@ -33,7 +33,6 @@ import ( "time" "github.com/moby/sys/mountinfo" - "golang.org/x/sys/unix" "k8s.io/klog/v2" utilexec "k8s.io/utils/exec" @@ -56,11 +55,6 @@ const ( errNotMounted = "not mounted" ) -var ( - // Error statx support since Linux 4.11, https://man7.org/linux/man-pages/man2/statx.2.html - errStatxNotSupport = errors.New("the statx syscall is not supported. At least Linux kernel 4.11 is needed") -) - // Mounter provides the default implementation of mount.Interface // for the linux platform. This implementation assumes that the // kubelet is running in the host's root mount namespace. @@ -391,20 +385,14 @@ func (*Mounter) List() ([]MountPoint, error) { return ListProcMounts(procMountsPath) } -func statx(file string) (unix.Statx_t, error) { - var stat unix.Statx_t - if err := unix.Statx(0, file, unix.AT_STATX_DONT_SYNC, 0, &stat); err != nil { - if err == unix.ENOSYS { - return stat, errStatxNotSupport - } - - return stat, err - } - - return stat, nil -} - -func (mounter *Mounter) isLikelyNotMountPointStat(file string) (bool, error) { +// IsLikelyNotMountPoint determines if a directory is not a mountpoint. +// It is fast but not necessarily ALWAYS correct. If the path is in fact +// a bind mount from one part of a mount to another it will not be detected. +// It also can not distinguish between mountpoints and symbolic links. +// mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") +// will return true. When in fact /tmp/b is a mount point. If this situation +// is of interest to you, don't use this function... +func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { stat, err := os.Stat(file) if err != nil { return true, err @@ -421,51 +409,6 @@ func (mounter *Mounter) isLikelyNotMountPointStat(file string) (bool, error) { return true, nil } -func (mounter *Mounter) isLikelyNotMountPointStatx(file string) (bool, error) { - var stat, rootStat unix.Statx_t - var err error - - if stat, err = statx(file); err != nil { - return true, err - } - - if stat.Attributes_mask != 0 { - if stat.Attributes_mask&unix.STATX_ATTR_MOUNT_ROOT != 0 { - if stat.Attributes&unix.STATX_ATTR_MOUNT_ROOT != 0 { - // file is a mountpoint - return false, nil - } else { - // no need to check rootStat if unix.STATX_ATTR_MOUNT_ROOT supported - return true, nil - } - } - } - - root := filepath.Dir(strings.TrimSuffix(file, "/")) - if rootStat, err = statx(root); err != nil { - return true, err - } - - return (stat.Dev_major == rootStat.Dev_major && stat.Dev_minor == rootStat.Dev_minor), nil -} - -// IsLikelyNotMountPoint determines if a directory is not a mountpoint. -// It is fast but not necessarily ALWAYS correct. If the path is in fact -// a bind mount from one part of a mount to another it will not be detected. -// It also can not distinguish between mountpoints and symbolic links. -// mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") -// will return true. When in fact /tmp/b is a mount point. If this situation -// is of interest to you, don't use this function... -func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { - notMountPoint, err := mounter.isLikelyNotMountPointStatx(file) - if errors.Is(err, errStatxNotSupport) { - // fall back to isLikelyNotMountPointStat - return mounter.isLikelyNotMountPointStat(file) - } - - return notMountPoint, err -} - // CanSafelySkipMountPointCheck relies on the detected behavior of umount when given a target that is not a mount point. func (mounter *Mounter) CanSafelySkipMountPointCheck() bool { return mounter.withSafeNotMountedBehavior diff --git a/vendor/k8s.io/mount-utils/mount_windows.go b/vendor/k8s.io/mount-utils/mount_windows.go index 9c8ad054f..be714646e 100644 --- a/vendor/k8s.io/mount-utils/mount_windows.go +++ b/vendor/k8s.io/mount-utils/mount_windows.go @@ -164,7 +164,7 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri // return (output, error) func newSMBMapping(username, password, remotepath string) (string, error) { if username == "" || password == "" || remotepath == "" { - return "", fmt.Errorf("invalid parameter(username: %s, password: %s, remotepath: %s)", username, sensitiveOptionsRemoved, remotepath) + return "", fmt.Errorf("invalid parameter(username: %s, password: %s, remoteapth: %s)", username, sensitiveOptionsRemoved, remotepath) } // use PowerShell Environment Variables to store user input string to prevent command line injection @@ -193,8 +193,8 @@ func isSMBMappingExist(remotepath string) bool { // check whether remotepath is valid // return (true, nil) if remotepath is valid func isValidPath(remotepath string) (bool, error) { - cmd := exec.Command("powershell", "/c", `Test-Path $Env:remotepath`) - cmd.Env = append(os.Environ(), fmt.Sprintf("remotepath=%s", remotepath)) + cmd := exec.Command("powershell", "/c", `Test-Path $Env:remoteapth`) + cmd.Env = append(os.Environ(), fmt.Sprintf("remoteapth=%s", remotepath)) output, err := cmd.CombinedOutput() if err != nil { return false, fmt.Errorf("returned output: %s, error: %v", string(output), err) diff --git a/vendor/modules.txt b/vendor/modules.txt index fceadcf5e..8d4b87d93 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1719,8 +1719,8 @@ k8s.io/kubernetes/test/utils k8s.io/kubernetes/test/utils/format k8s.io/kubernetes/test/utils/image k8s.io/kubernetes/test/utils/kubeconfig -# k8s.io/mount-utils v0.30.0 => k8s.io/mount-utils v0.30.0 -## explicit; go 1.22.0 +# k8s.io/mount-utils v0.30.0 => k8s.io/mount-utils v0.29.3 +## explicit; go 1.21 k8s.io/mount-utils # k8s.io/pod-security-admission v0.30.0 => k8s.io/pod-security-admission v0.30.0 ## explicit; go 1.22.0 @@ -1832,7 +1832,7 @@ sigs.k8s.io/yaml/goyaml.v2 # k8s.io/kubelet => k8s.io/kubelet v0.30.0 # k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.0 # k8s.io/metrics => k8s.io/metrics v0.30.0 -# k8s.io/mount-utils => k8s.io/mount-utils v0.30.0 +# k8s.io/mount-utils => k8s.io/mount-utils v0.29.3 # k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.30.0 # k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.30.0 # layeh.com/radius => github.com/layeh/radius v0.0.0-20190322222518-890bc1058917