From 9cfdc4f51ba89f7a09b6d2a17eb85a7c45260abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 16 Oct 2019 11:19:24 +0200 Subject: [PATCH] ceph: detect mount fstype more accurately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using `df --type ceph` has proven not to be reliable enough, so let's try with findmnt. Closes: https://github.com/rook/rook/issues/4107 Signed-off-by: Sébastien Han --- cmd/rookflex/cmd/unmount.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/rookflex/cmd/unmount.go b/cmd/rookflex/cmd/unmount.go index bf3d8a666..60fa898b7 100644 --- a/cmd/rookflex/cmd/unmount.go +++ b/cmd/rookflex/cmd/unmount.go @@ -20,6 +20,7 @@ import ( "fmt" "net/rpc" "os/exec" + "strings" "github.com/rook/rook/pkg/daemon/ceph/agent/flexvolume" "github.com/spf13/cobra" @@ -50,10 +51,12 @@ func handleUnmount(cmd *cobra.Command, args []string) error { mounter := getMounter() - // Check if it's a cephfs - command := exec.Command("df", "--type", cephFS, mountDir) - err = command.Run() - if err == nil { + // Check if it's a cephfs mount + fstype, err := exec.Command("findmnt", "--nofsroot", "--noheadings", "--output", "FSTYPE", "--submounts", "--target", mountDir).Output() + if err != nil { + return fmt.Errorf("failed to retrieve filesystem type for path %q. %+v", mountDir, err) + } + if strings.Contains(string(fstype), "ceph") { return unmountCephFS(client, mounter, mountDir) }