mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
cleanup: added helper func isNotMountPoint
Added helper func isNotMountPoint to check mountPoint, validate error and reduce complexity of NodeStageVolume. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
@ -38,6 +38,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/cloud-provider/volume/helpers"
|
||||
mount "k8s.io/mount-utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -455,6 +456,16 @@ func checkImageFeatures(imageFeatures string, ok, static bool) bool {
|
||||
return static && (!ok || imageFeatures == "")
|
||||
}
|
||||
|
||||
// isNotMountPoint checks whether MountPoint does not exists and
|
||||
// also discards error indicating mountPoint exists.
|
||||
func isNotMountPoint(mounter mount.Interface, stagingTargetPath string) (bool, error) {
|
||||
isNotMnt, err := mount.IsNotMountPoint(mounter, stagingTargetPath)
|
||||
if os.IsNotExist(err) {
|
||||
err = nil
|
||||
}
|
||||
return isNotMnt, err
|
||||
}
|
||||
|
||||
// addRbdManagerTask adds a ceph manager task to execute command
|
||||
// asynchronously. If command is not found returns a bool set to false
|
||||
// example arg ["trash", "remove","pool/image"].
|
||||
|
Reference in New Issue
Block a user