mirror of https://github.com/k3s-io/k3s
Fixed subpath cleanup when /var/lib/kubelet is a symlink.
parent
e763a3c56d
commit
9e24ccbda0
|
@ -251,9 +251,14 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
|
||||||
// It is more extensive than IsLikelyNotMountPoint
|
// It is more extensive than IsLikelyNotMountPoint
|
||||||
// and it detects bind mounts in linux
|
// and it detects bind mounts in linux
|
||||||
func IsNotMountPoint(mounter Interface, file string) (bool, error) {
|
func IsNotMountPoint(mounter Interface, file string) (bool, error) {
|
||||||
|
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts
|
||||||
|
resolvedFile, err := mounter.EvalHostSymlinks(file)
|
||||||
|
if err != nil {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
// IsLikelyNotMountPoint provides a quick check
|
// IsLikelyNotMountPoint provides a quick check
|
||||||
// to determine whether file IS A mountpoint
|
// to determine whether file IS A mountpoint
|
||||||
notMnt, notMntErr := mounter.IsLikelyNotMountPoint(file)
|
notMnt, notMntErr := mounter.IsLikelyNotMountPoint(resolvedFile)
|
||||||
if notMntErr != nil && os.IsPermission(notMntErr) {
|
if notMntErr != nil && os.IsPermission(notMntErr) {
|
||||||
// We were not allowed to do the simple stat() check, e.g. on NFS with
|
// We were not allowed to do the simple stat() check, e.g. on NFS with
|
||||||
// root_squash. Fall back to /proc/mounts check below.
|
// root_squash. Fall back to /proc/mounts check below.
|
||||||
|
@ -274,7 +279,7 @@ func IsNotMountPoint(mounter Interface, file string) (bool, error) {
|
||||||
return notMnt, mountPointsErr
|
return notMnt, mountPointsErr
|
||||||
}
|
}
|
||||||
for _, mp := range mountPoints {
|
for _, mp := range mountPoints {
|
||||||
if mounter.IsMountPointMatch(mp, file) {
|
if mounter.IsMountPointMatch(mp, resolvedFile) {
|
||||||
notMnt = false
|
notMnt = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue