From 14276bf642880a23e1e66e172a2a0a7ef9315f45 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 9 Apr 2020 17:14:43 +0200 Subject: [PATCH] rbd: fallback to inline image deletion if adding it as a task fails Fixes: #858 Signed-off-by: Niels de Vos --- pkg/rbd/rbd_util.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index cbf9f5ab0..69fb982c9 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -236,16 +236,18 @@ func rbdManagerTaskDeleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.C output, err := execCommand("ceph", args) if err != nil { - if strings.Contains(string(output), rbdTaskRemoveCmdInvalidString1) && - strings.Contains(string(output), rbdTaskRemoveCmdInvalidString2) { + switch { + case strings.Contains(string(output), rbdTaskRemoveCmdInvalidString1) && + strings.Contains(string(output), rbdTaskRemoveCmdInvalidString2): klog.Warningf(util.Log(ctx, "cluster with cluster ID (%s) does not support Ceph manager based rbd image"+ " deletion (minimum ceph version required is v14.2.3)"), pOpts.ClusterID) - return false, err - } else if strings.HasPrefix(string(output), rbdTaskRemoveCmdAccessDeniedMessage) { + case strings.HasPrefix(string(output), rbdTaskRemoveCmdAccessDeniedMessage): klog.Warningf(util.Log(ctx, "access denied to Ceph MGR-based RBD image deletion "+ "on cluster ID (%s)"), pOpts.ClusterID) - return false, err + default: + klog.Warningf(util.Log(ctx, "uncaught error while scheduling an image deletion task: %s"), err) } + return false, err } return true, err