From a274b19bfa66de2406eea19cabfbdfa079d463cf Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 10 Oct 2019 10:30:58 -0400 Subject: [PATCH] Handle EACCESS error from 'ceph rbd task add remove' If the RBD user does not have permissions to talk to the Ceph MGR, it should gracefully fallback to the slower foreground image deletion. Fixes: #677 Signed-off-by: Jason Dillaman --- pkg/rbd/rbd_util.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index afb7b5153..af1d2c57e 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -50,8 +50,9 @@ const ( // Output strings returned during invocation of "ceph rbd task add remove " when // command is not supported by ceph manager. Used to check errors and recover when the command // is unsupported. - rbdTaskRemoveCmdInvalidString1 = "no valid command found" - rbdTaskRemoveCmdInvalidString2 = "Error EINVAL: invalid command" + rbdTaskRemoveCmdInvalidString1 = "no valid command found" + rbdTaskRemoveCmdInvalidString2 = "Error EINVAL: invalid command" + rbdTaskRemoveCmdAccessDeniedMessage = "Error EACCES:" ) // rbdVolume represents a CSI volume and its RBD image specifics @@ -185,6 +186,10 @@ func rbdManagerTaskDeleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.C klog.Infof(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) { + klog.Infof(util.Log(ctx, "access denied to Ceph MGR-based RBD image deletion "+ + "on cluster ID (%s)"), pOpts.ClusterID) + return false, err } }