From 983a570b9e3e48259c91d7264bbfbcfd91eb6d66 Mon Sep 17 00:00:00 2001 From: Carter McKinnon Date: Wed, 25 May 2022 17:31:54 -0700 Subject: [PATCH] Take canSafelySkipMountPointCheck package-private, reduce log visibility for removePath. --- staging/src/k8s.io/mount-utils/fake_mounter.go | 2 +- staging/src/k8s.io/mount-utils/mount.go | 4 ++-- staging/src/k8s.io/mount-utils/mount_helper_common.go | 10 +++++----- staging/src/k8s.io/mount-utils/mount_linux.go | 4 ++-- staging/src/k8s.io/mount-utils/mount_unsupported.go | 4 ++-- staging/src/k8s.io/mount-utils/mount_windows.go | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/staging/src/k8s.io/mount-utils/fake_mounter.go b/staging/src/k8s.io/mount-utils/fake_mounter.go index 73839fbe325..51e21980527 100644 --- a/staging/src/k8s.io/mount-utils/fake_mounter.go +++ b/staging/src/k8s.io/mount-utils/fake_mounter.go @@ -218,7 +218,7 @@ func (f *FakeMounter) IsLikelyNotMountPoint(file string) (bool, error) { return true, nil } -func (f *FakeMounter) CanSafelySkipMountPointCheck() bool { +func (f *FakeMounter) canSafelySkipMountPointCheck() bool { return f.skipMountPointCheck } diff --git a/staging/src/k8s.io/mount-utils/mount.go b/staging/src/k8s.io/mount-utils/mount.go index a6c20155a3d..eca644046f3 100644 --- a/staging/src/k8s.io/mount-utils/mount.go +++ b/staging/src/k8s.io/mount-utils/mount.go @@ -66,10 +66,10 @@ type Interface interface { // care about such situations, this is a faster alternative to calling List() // and scanning that output. IsLikelyNotMountPoint(file string) (bool, error) - // CanSafelySkipMountPointCheck indicates whether this mounter returns errors on + // canSafelySkipMountPointCheck indicates whether this mounter returns errors on // operations for targets that are not mount points. If this returns true, no such // errors will be returned. - CanSafelySkipMountPointCheck() bool + canSafelySkipMountPointCheck() bool // GetMountRefs finds all mount references to pathname, returning a slice of // paths. Pathname can be a mountpoint path or a normal directory // (for bind mount). On Linux, pathname is excluded from the slice. diff --git a/staging/src/k8s.io/mount-utils/mount_helper_common.go b/staging/src/k8s.io/mount-utils/mount_helper_common.go index 69b2849d00d..7f590ae1936 100644 --- a/staging/src/k8s.io/mount-utils/mount_helper_common.go +++ b/staging/src/k8s.io/mount-utils/mount_helper_common.go @@ -53,7 +53,7 @@ func CleanupMountWithForce(mountPath string, mounter MounterForceUnmounter, exte } var notMnt bool var err error - if !mounter.CanSafelySkipMountPointCheck() && !corruptedMnt { + if !mounter.canSafelySkipMountPointCheck() && !corruptedMnt { notMnt, err = removePathIfNotMountPoint(mountPath, mounter, extensiveMountPointCheck) // if mountPath was not a mount point - we would have attempted to remove mountPath // and hence return errors if any. @@ -68,7 +68,7 @@ func CleanupMountWithForce(mountPath string, mounter MounterForceUnmounter, exte return err } - if mounter.CanSafelySkipMountPointCheck() { + if mounter.canSafelySkipMountPointCheck() { return removePath(mountPath) } @@ -90,7 +90,7 @@ func CleanupMountWithForce(mountPath string, mounter MounterForceUnmounter, exte func doCleanupMountPoint(mountPath string, mounter Interface, extensiveMountPointCheck bool, corruptedMnt bool) error { var notMnt bool var err error - if !mounter.CanSafelySkipMountPointCheck() && !corruptedMnt { + if !mounter.canSafelySkipMountPointCheck() && !corruptedMnt { notMnt, err = removePathIfNotMountPoint(mountPath, mounter, extensiveMountPointCheck) // if mountPath was not a mount point - we would have attempted to remove mountPath // and hence return errors if any. @@ -105,7 +105,7 @@ func doCleanupMountPoint(mountPath string, mounter Interface, extensiveMountPoin return err } - if mounter.CanSafelySkipMountPointCheck() { + if mounter.canSafelySkipMountPointCheck() { return removePath(mountPath) } @@ -146,7 +146,7 @@ func removePathIfNotMountPoint(mountPath string, mounter Interface, extensiveMou // removePath attempts to remove the directory. Returns nil if the directory was removed or does not exist. func removePath(mountPath string) error { - klog.Warningf("Warning: deleting path %q", mountPath) + klog.V(4).Infof("Warning: deleting path %q", mountPath) err := os.Remove(mountPath) if os.IsNotExist(err) { klog.V(4).Infof("%q does not exist", mountPath) diff --git a/staging/src/k8s.io/mount-utils/mount_linux.go b/staging/src/k8s.io/mount-utils/mount_linux.go index 333035fd562..0eb03db83f0 100644 --- a/staging/src/k8s.io/mount-utils/mount_linux.go +++ b/staging/src/k8s.io/mount-utils/mount_linux.go @@ -393,8 +393,8 @@ func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { return true, nil } -// CanSafelySkipMountPointCheck relies on the detected behavior of umount when given a target that is not a mount point. -func (mounter *Mounter) CanSafelySkipMountPointCheck() bool { +// 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/staging/src/k8s.io/mount-utils/mount_unsupported.go b/staging/src/k8s.io/mount-utils/mount_unsupported.go index 817d9e3e76e..f3b18c15145 100644 --- a/staging/src/k8s.io/mount-utils/mount_unsupported.go +++ b/staging/src/k8s.io/mount-utils/mount_unsupported.go @@ -74,8 +74,8 @@ func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { return true, errUnsupported } -// CanSafelySkipMountPointCheck always returns false on unsupported platforms -func (mounter *Mounter) CanSafelySkipMountPointCheck() bool { +// canSafelySkipMountPointCheck always returns false on unsupported platforms +func (mounter *Mounter) canSafelySkipMountPointCheck() bool { return false } diff --git a/staging/src/k8s.io/mount-utils/mount_windows.go b/staging/src/k8s.io/mount-utils/mount_windows.go index d35fdc85afa..c7fcde5fc98 100644 --- a/staging/src/k8s.io/mount-utils/mount_windows.go +++ b/staging/src/k8s.io/mount-utils/mount_windows.go @@ -244,8 +244,8 @@ func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { return true, nil } -// CanSafelySkipMountPointCheck always returns false on Windows -func (mounter *Mounter) CanSafelySkipMountPointCheck() bool { +// canSafelySkipMountPointCheck always returns false on Windows +func (mounter *Mounter) canSafelySkipMountPointCheck() bool { return false }