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 <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2023-11-27 17:31:05 +01:00
parent c21cba2c52
commit a9eae1e4f8

View File

@ -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)