Take canSafelySkipMountPointCheck package-private, reduce log visibility for removePath.

This commit is contained in:
Carter McKinnon 2022-05-25 17:31:54 -07:00
parent 7e67428056
commit 983a570b9e
6 changed files with 14 additions and 14 deletions

View File

@ -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
}

View File

@ -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.

View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}