From 721640178b7624755a9dbae80f53ad4a256eff29 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Wed, 17 Mar 2021 11:48:36 +0530 Subject: [PATCH] cephfs: fix unmountVolume function This commit fixes bug in unmount function which caused unmountVolume to fail when targetPath was already unmounted. Signed-off-by: Rakshith R --- internal/cephfs/volumemounter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/cephfs/volumemounter.go b/internal/cephfs/volumemounter.go index 19f6f0463..dd7ce1d4f 100644 --- a/internal/cephfs/volumemounter.go +++ b/internal/cephfs/volumemounter.go @@ -257,8 +257,9 @@ func bindMount(ctx context.Context, from, to string, readOnly bool, mntOptions [ } func unmountVolume(ctx context.Context, mountPoint string) error { - if err := execCommandErr(ctx, "umount", mountPoint); err != nil { - if strings.Contains(err.Error(), fmt.Sprintf("exit status 32: umount: %s: not mounted", mountPoint)) || + if _, stderr, err := util.ExecCommand(ctx, "umount", mountPoint); err != nil { + err = fmt.Errorf("%w stderr: %s", err, stderr) + if strings.Contains(err.Error(), fmt.Sprintf("umount: %s: not mounted", mountPoint)) || strings.Contains(err.Error(), "No such file or directory") { return nil }