From 8512318efa35d34e1c4bdc28a8f6ebffa7313f9a Mon Sep 17 00:00:00 2001 From: Michael 'ASAP' Weinrich Date: Tue, 10 Dec 2024 11:57:44 -0800 Subject: [PATCH] moved call to `ceph.mount` to it's own function --- internal/server/device/device_utils_disk.go | 7 +------ internal/server/storage/drivers/utils.go | 7 +------ internal/server/storage/drivers/utils_ceph.go | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/internal/server/device/device_utils_disk.go b/internal/server/device/device_utils_disk.go index 899337e7170..203f1ebc4af 100644 --- a/internal/server/device/device_utils_disk.go +++ b/internal/server/device/device_utils_disk.go @@ -138,12 +138,7 @@ func DiskMount(srcPath string, dstPath string, recursive bool, propagation strin // Mount the filesystem if fsName == "ceph" { - // shell out to `mount.ceph` to do the work of - // determining monitor addresses and keyring - _, err = subprocess.RunCommand( - "mount.ceph", srcPath, dstPath, - "-o", mountOptionsStr, - ) + storageDrivers.CephMount(srcPath, dstPath, mountOptionsStr) } else { err = unix.Mount(srcPath, dstPath, fsName, uintptr(flags), mountOptionsStr) } diff --git a/internal/server/storage/drivers/utils.go b/internal/server/storage/drivers/utils.go index 8481ad9ef57..78eda21a24b 100644 --- a/internal/server/storage/drivers/utils.go +++ b/internal/server/storage/drivers/utils.go @@ -165,12 +165,7 @@ func TryMount(src string, dst string, fs string, flags uintptr, options string) var err error if fs == "ceph" { - // shell out to `mount.ceph` to do the work of - // determining monitor addresses and keyring - _, err = subprocess.RunCommand( - "mount.ceph", src, dst, - "-o", options, - ) + err = CephMount(src, dst, options) } else { // Attempt 20 mounts over 10s for i := 0; i < 20; i++ { diff --git a/internal/server/storage/drivers/utils_ceph.go b/internal/server/storage/drivers/utils_ceph.go index e3d95b6dc68..6aca2722dcf 100644 --- a/internal/server/storage/drivers/utils_ceph.go +++ b/internal/server/storage/drivers/utils_ceph.go @@ -160,3 +160,18 @@ func CephFSID(cluster string) (string, error) { fsid = strings.TrimSpace(fsid) return fsid, nil } + +// Attempts to mount Ceph via the `ceph.mount` helper. +func CephMount(src string, dst string, options string) error { + args := []string{ + src, + dst, + } + if options != "" { + args = append(args, "-o", options) + } + + _, err := subprocess.RunCommand("mount.ceph", args...) + + return err +}