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 <dillaman@redhat.com>
(cherry picked from commit a274b19bfa)
This commit is contained in:
Jason Dillaman 2019-10-10 10:30:58 -04:00 committed by mergify[bot]
parent a1cfc9c9ce
commit 2d16bc3ee9

View File

@ -52,6 +52,7 @@ const (
// is unsupported. // is unsupported.
rbdTaskRemoveCmdInvalidString1 = "no valid command found" rbdTaskRemoveCmdInvalidString1 = "no valid command found"
rbdTaskRemoveCmdInvalidString2 = "Error EINVAL: invalid command" rbdTaskRemoveCmdInvalidString2 = "Error EINVAL: invalid command"
rbdTaskRemoveCmdAccessDeniedMessage = "Error EACCES:"
) )
// rbdVolume represents a CSI volume and its RBD image specifics // rbdVolume represents a CSI volume and its RBD image specifics
@ -182,6 +183,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"+ 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) " deletion (minimum ceph version required is v14.2.3)"), pOpts.ClusterID)
return false, err 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
} }
} }