1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-20 03:50:24 +00:00

build: replace k8s.io/mount-utils to v0.29.3

Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
Praveen M 2024-05-22 17:39:00 +05:30 committed by mergify[bot]
parent 24112917ec
commit a8e9d66009
5 changed files with 19 additions and 74 deletions

4
go.mod
View File

@ -223,7 +223,9 @@ replace (
k8s.io/kubelet => k8s.io/kubelet v0.30.0 k8s.io/kubelet => k8s.io/kubelet v0.30.0
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers 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/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/pod-security-admission => k8s.io/pod-security-admission v0.30.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.30.0 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.30.0
// layeh.com seems to be misbehaving // layeh.com seems to be misbehaving

4
go.sum
View File

@ -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/kubelet v0.30.0/go.mod h1:WukdKqbQxnj+csn3K8XOKeX7Sh60J/da25IILjvvB5s=
k8s.io/kubernetes v1.30.0 h1:u3Yw8rNlo2NDSGaDpoxoHXLPQnEu1tfqHATKOJe94HY= k8s.io/kubernetes v1.30.0 h1:u3Yw8rNlo2NDSGaDpoxoHXLPQnEu1tfqHATKOJe94HY=
k8s.io/kubernetes v1.30.0/go.mod h1:yPbIk3MhmhGigX62FLJm+CphNtjxqCvAIFQXup6RKS0= 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.29.3 h1:iEcqPP7Vv8UClH8nnMfovtmy/04fIloRW9JuSXykoZ0=
k8s.io/mount-utils v0.30.0/go.mod h1:9sCVmwGLcV1MPvbZ+rToMDnl1QcGozy+jBPd0MsQLIo= 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 h1:C8J/zbrA3hVR7jatN+mN/ymUWxwU6KceS5HsEEt6rTY=
k8s.io/pod-security-admission v0.30.0/go.mod h1:eyzZB+gtMwnNduqr9tVO2vjf2DdepZsUA11SzyfXhfM= 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= k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=

View File

@ -33,7 +33,6 @@ import (
"time" "time"
"github.com/moby/sys/mountinfo" "github.com/moby/sys/mountinfo"
"golang.org/x/sys/unix"
"k8s.io/klog/v2" "k8s.io/klog/v2"
utilexec "k8s.io/utils/exec" utilexec "k8s.io/utils/exec"
@ -56,11 +55,6 @@ const (
errNotMounted = "not mounted" 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 // Mounter provides the default implementation of mount.Interface
// for the linux platform. This implementation assumes that the // for the linux platform. This implementation assumes that the
// kubelet is running in the host's root mount namespace. // kubelet is running in the host's root mount namespace.
@ -391,20 +385,14 @@ func (*Mounter) List() ([]MountPoint, error) {
return ListProcMounts(procMountsPath) return ListProcMounts(procMountsPath)
} }
func statx(file string) (unix.Statx_t, error) { // IsLikelyNotMountPoint determines if a directory is not a mountpoint.
var stat unix.Statx_t // It is fast but not necessarily ALWAYS correct. If the path is in fact
if err := unix.Statx(0, file, unix.AT_STATX_DONT_SYNC, 0, &stat); err != nil { // a bind mount from one part of a mount to another it will not be detected.
if err == unix.ENOSYS { // It also can not distinguish between mountpoints and symbolic links.
return stat, errStatxNotSupport // 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...
return stat, err func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
}
return stat, nil
}
func (mounter *Mounter) isLikelyNotMountPointStat(file string) (bool, error) {
stat, err := os.Stat(file) stat, err := os.Stat(file)
if err != nil { if err != nil {
return true, err return true, err
@ -421,51 +409,6 @@ func (mounter *Mounter) isLikelyNotMountPointStat(file string) (bool, error) {
return true, nil 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. // CanSafelySkipMountPointCheck relies on the detected behavior of umount when given a target that is not a mount point.
func (mounter *Mounter) CanSafelySkipMountPointCheck() bool { func (mounter *Mounter) CanSafelySkipMountPointCheck() bool {
return mounter.withSafeNotMountedBehavior return mounter.withSafeNotMountedBehavior

View File

@ -164,7 +164,7 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
// return (output, error) // return (output, error)
func newSMBMapping(username, password, remotepath string) (string, error) { func newSMBMapping(username, password, remotepath string) (string, error) {
if username == "" || password == "" || remotepath == "" { 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 // 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 // check whether remotepath is valid
// return (true, nil) if remotepath is valid // return (true, nil) if remotepath is valid
func isValidPath(remotepath string) (bool, error) { func isValidPath(remotepath string) (bool, error) {
cmd := exec.Command("powershell", "/c", `Test-Path $Env:remotepath`) cmd := exec.Command("powershell", "/c", `Test-Path $Env:remoteapth`)
cmd.Env = append(os.Environ(), fmt.Sprintf("remotepath=%s", remotepath)) cmd.Env = append(os.Environ(), fmt.Sprintf("remoteapth=%s", remotepath))
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
if err != nil { if err != nil {
return false, fmt.Errorf("returned output: %s, error: %v", string(output), err) return false, fmt.Errorf("returned output: %s, error: %v", string(output), err)

6
vendor/modules.txt vendored
View File

@ -1719,8 +1719,8 @@ k8s.io/kubernetes/test/utils
k8s.io/kubernetes/test/utils/format k8s.io/kubernetes/test/utils/format
k8s.io/kubernetes/test/utils/image k8s.io/kubernetes/test/utils/image
k8s.io/kubernetes/test/utils/kubeconfig k8s.io/kubernetes/test/utils/kubeconfig
# k8s.io/mount-utils v0.30.0 => k8s.io/mount-utils v0.30.0 # k8s.io/mount-utils v0.30.0 => k8s.io/mount-utils v0.29.3
## explicit; go 1.22.0 ## explicit; go 1.21
k8s.io/mount-utils k8s.io/mount-utils
# k8s.io/pod-security-admission v0.30.0 => k8s.io/pod-security-admission v0.30.0 # k8s.io/pod-security-admission v0.30.0 => k8s.io/pod-security-admission v0.30.0
## explicit; go 1.22.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/kubelet => k8s.io/kubelet v0.30.0
# k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers 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/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/pod-security-admission => k8s.io/pod-security-admission v0.30.0
# k8s.io/sample-apiserver => k8s.io/sample-apiserver 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 # layeh.com/radius => github.com/layeh/radius v0.0.0-20190322222518-890bc1058917