mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-24 14:00:19 +00:00
rbd: do not return an error when deleting a non-existing image
Deleting an image that has been already remove, should not be reported as a failure. This improves the idempotency of the `rbdImage.Delete()` function, making it easier for callers to detect real errors. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
88b964fe18
commit
611e5d920e
@ -671,7 +671,7 @@ func (ri *rbdImage) Delete(ctx context.Context) error {
|
||||
|
||||
rbdImage := librbd.GetImage(ri.ioctx, image)
|
||||
err = rbdImage.Trash(0)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, librbd.ErrNotFound) {
|
||||
log.ErrorLog(ctx, "failed to delete rbd image: %s, error: %v", ri, err)
|
||||
|
||||
return err
|
||||
@ -694,7 +694,7 @@ func (ri *rbdImage) trashRemoveImage(ctx context.Context) error {
|
||||
_, err = ta.AddTrashRemove(admin.NewImageSpec(ri.Pool, ri.RadosNamespace, ri.ImageID))
|
||||
|
||||
rbdCephMgrSupported := isCephMgrSupported(ctx, ri.ClusterID, err)
|
||||
if rbdCephMgrSupported && err != nil {
|
||||
if rbdCephMgrSupported && err != nil && !errors.Is(err, librbd.ErrNotFound) {
|
||||
log.ErrorLog(ctx, "failed to add task to delete rbd image: %s, %v", ri, err)
|
||||
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user