mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: bump k8s.io/kubernetes from 1.22.3 to 1.22.4
Bumps [k8s.io/kubernetes](https://github.com/kubernetes/kubernetes) from 1.22.3 to 1.22.4. - [Release notes](https://github.com/kubernetes/kubernetes/releases) - [Commits](https://github.com/kubernetes/kubernetes/compare/v1.22.3...v1.22.4) --- updated-dependencies: - dependency-name: k8s.io/kubernetes dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
929e17d21b
commit
b2099eb3b1
26
vendor/k8s.io/kubernetes/pkg/volume/util/subpath/subpath_linux.go
generated
vendored
26
vendor/k8s.io/kubernetes/pkg/volume/util/subpath/subpath_linux.go
generated
vendored
@ -29,7 +29,6 @@ import (
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/volume/util/hostutil"
|
||||
"k8s.io/mount-utils"
|
||||
)
|
||||
|
||||
@ -109,12 +108,12 @@ func prepareSubpathTarget(mounter mount.Interface, subpath Subpath) (bool, strin
|
||||
notMount = true
|
||||
}
|
||||
if !notMount {
|
||||
linuxHostUtil := hostutil.NewHostUtil()
|
||||
mntInfo, err := linuxHostUtil.FindMountInfo(bindPathTarget)
|
||||
// It's already mounted, so check if it's bind-mounted to the same path
|
||||
samePath, err := checkSubPathFileEqual(subpath, bindPathTarget)
|
||||
if err != nil {
|
||||
return false, "", fmt.Errorf("error calling findMountInfo for %s: %s", bindPathTarget, err)
|
||||
return false, "", fmt.Errorf("error checking subpath mount info for %s: %s", bindPathTarget, err)
|
||||
}
|
||||
if mntInfo.Root != subpath.Path {
|
||||
if !samePath {
|
||||
// It's already mounted but not what we want, unmount it
|
||||
if err = mounter.Unmount(bindPathTarget); err != nil {
|
||||
return false, "", fmt.Errorf("error ummounting %s: %s", bindPathTarget, err)
|
||||
@ -155,6 +154,23 @@ func prepareSubpathTarget(mounter mount.Interface, subpath Subpath) (bool, strin
|
||||
return false, bindPathTarget, nil
|
||||
}
|
||||
|
||||
func checkSubPathFileEqual(subpath Subpath, bindMountTarget string) (bool, error) {
|
||||
s, err := os.Lstat(subpath.Path)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("stat %s failed: %s", subpath.Path, err)
|
||||
}
|
||||
|
||||
t, err := os.Lstat(bindMountTarget)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("lstat %s failed: %s", bindMountTarget, err)
|
||||
}
|
||||
|
||||
if !os.SameFile(s, t) {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getSubpathBindTarget(subpath Subpath) string {
|
||||
// containerName is DNS label, i.e. safe as a directory name.
|
||||
return filepath.Join(subpath.PodDir, containerSubPathDirectoryName, subpath.VolumeName, subpath.ContainerName, strconv.Itoa(subpath.VolumeMountIndex))
|
||||
|
Reference in New Issue
Block a user