From 8f185bf7b27ff2d3adc8c178473fb4367fefce37 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 27 Jul 2021 12:13:39 +0530 Subject: [PATCH] rbd: use rados namespace for manager command Currently we have a bug that we are not using rados namespace when adding ceph manager command to remove the image from the trash. This commit adds the missing rados namespace when adding ceph manager task. without fix the image will be moved to trash and no task will be added to remove from the trash. it will become ceph responsibility to remove the image from trash when it will cleanup the trash. workaroud: manually purge the trash Signed-off-by: Madhu Rajanna --- internal/rbd/rbd_util.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 51d927c96..858cce1bd 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -523,6 +523,16 @@ func addRbdManagerTask(ctx context.Context, pOpts *rbdVolume, arg []string) (boo return supported, err } +// getTrashPath returns the image path for trash operation. +func (rv *rbdVolume) getTrashPath() string { + trashPath := rv.Pool + if rv.RadosNamespace != "" { + trashPath = trashPath + "/" + rv.RadosNamespace + } + + return trashPath + "/" + rv.ImageID +} + // deleteImage deletes a ceph image with provision and volume options. func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) error { image := pOpts.RbdImageName @@ -556,9 +566,10 @@ func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) er } // attempt to use Ceph manager based deletion support if available + args := []string{ "trash", "remove", - pOpts.Pool + "/" + pOpts.ImageID, + pOpts.getTrashPath(), "--id", cr.ID, "--keyfile=" + cr.KeyFile, "-m", pOpts.Monitors,