From a9eae1e4f88dbac4ea784ef665b1244b38b2eae0 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 27 Nov 2023 17:31:05 +0100 Subject: [PATCH] rbd: the DeleteVolume CSI procedure should succeed on deleted images If the RBD-image is deleted already, the DeleteVolume CSI procedure is expected to report success (as it should be idempotent). In case the returned error indicates "RBD image not found", the error is ignored and the DeleteVolume procedure continues. Signed-off-by: Niels de Vos --- internal/rbd/controllerserver.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 9037e1c23..7ad5378ea 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -1017,9 +1017,10 @@ func cleanupRBDImage(ctx context.Context, } } - // Deleting rbd image + // Deleting rbd image, it isn't a failure if the image was deleted already. log.DebugLog(ctx, "deleting image %s", rbdVol.RbdImageName) - if err = rbdVol.deleteImage(ctx); err != nil { + err = rbdVol.deleteImage(ctx) + if err != nil && !errors.Is(err, librbd.ErrNotFound) { log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, err)