mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
cleanup: create k8s.io/mount-utils Mounter only once
Recently the k8s.io/mount-utils package added more runtime dectection. When creating a new Mounter, the detect is run every time. This is unfortunate, as it logs a message like the following: ``` mount_linux.go:283] Detected umount with safe 'not mounted' behavior ``` This message might be useful, so it probably good to keep it. In Ceph-CSI there are various locations where Mounter instances are created. Moving that to the DefaultNodeServer type reduces it to a single place. Some utility functions need to accept the additional parameter too, so that has been modified as well. See-also: kubernetes/kubernetes#109676 Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
5ed305850f
commit
011d4fc81c
@ -325,9 +325,8 @@ func checkDirExists(p string) bool {
|
||||
}
|
||||
|
||||
// IsMountPoint checks if the given path is mountpoint or not.
|
||||
func IsMountPoint(p string) (bool, error) {
|
||||
dummyMount := mount.New("")
|
||||
notMnt, err := dummyMount.IsLikelyNotMountPoint(p)
|
||||
func IsMountPoint(mounter mount.Interface, p string) (bool, error) {
|
||||
notMnt, err := mounter.IsLikelyNotMountPoint(p)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -348,10 +347,8 @@ func ReadMountInfoForProc(proc string) ([]mount.MountInfo, error) {
|
||||
}
|
||||
|
||||
// Mount mounts the source to target path.
|
||||
func Mount(source, target, fstype string, options []string) error {
|
||||
dummyMount := mount.New("")
|
||||
|
||||
return dummyMount.MountSensitiveWithoutSystemd(source, target, fstype, options, nil)
|
||||
func Mount(mounter mount.Interface, source, target, fstype string, options []string) error {
|
||||
return mounter.MountSensitiveWithoutSystemd(source, target, fstype, options, nil)
|
||||
}
|
||||
|
||||
// MountOptionsAdd adds the `add` mount options to the `options` and returns a
|
||||
|
Reference in New Issue
Block a user