From a9174dd9531f2faf8265d86fb1679db7fccff365 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 16 Mar 2020 10:29:16 +0530 Subject: [PATCH] Fix logging if the rbd manager command is supported if there is an error when adding the rbd task we are logging the output which is empty. This PR logs the error if the rbd task is supported and there is an error. Signed-off-by: Madhu Rajanna --- pkg/rbd/rbd_util.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index b746049d5..913362e35 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -269,15 +269,19 @@ func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) er // attempt to use Ceph manager based deletion support if available rbdCephMgrSupported, err := rbdManagerTaskDeleteImage(ctx, pOpts, cr) + if rbdCephMgrSupported && err != nil { + klog.Errorf(util.Log(ctx, "failed to add task to delete rbd image: %s/%s, %v"), pOpts.Pool, image, err) + return err + } + if !rbdCephMgrSupported { // attempt older style deletion args := []string{"rm", image, "--pool", pOpts.Pool, "--id", cr.ID, "-m", pOpts.Monitors, "--keyfile=" + cr.KeyFile} output, err = execCommand("rbd", args) - } - - if err != nil { - klog.Errorf(util.Log(ctx, "failed to delete rbd image: %v, command output: %s"), err, string(output)) + if err != nil { + klog.Errorf(util.Log(ctx, "failed to delete rbd image: %s/%s, error: %v, command output: %s"), pOpts.Pool, image, err, string(output)) + } } return err