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 <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-07-27 12:13:39 +05:30 committed by mergify[bot]
parent d14c0afe28
commit 8f185bf7b2

View File

@ -523,6 +523,16 @@ func addRbdManagerTask(ctx context.Context, pOpts *rbdVolume, arg []string) (boo
return supported, err 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. // deleteImage deletes a ceph image with provision and volume options.
func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) error { func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) error {
image := pOpts.RbdImageName 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 // attempt to use Ceph manager based deletion support if available
args := []string{ args := []string{
"trash", "remove", "trash", "remove",
pOpts.Pool + "/" + pOpts.ImageID, pOpts.getTrashPath(),
"--id", cr.ID, "--id", cr.ID,
"--keyfile=" + cr.KeyFile, "--keyfile=" + cr.KeyFile,
"-m", pOpts.Monitors, "-m", pOpts.Monitors,