From e0a1c82cba8a8730f0c98260cb891ee56a570d7e Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Sun, 4 Dec 2022 22:42:47 +0200 Subject: [PATCH] core: fix async task-less execution of remove-image RemoveImage may lack async tasks when: 1. The image doesn't exist 2. There's a failure during delete image With these changes, the image is removed from the database (rather than staying in LOCKED state) and the command would finish successfully in the first case, and in the second case the command end with failure and the image switches to ILLEGAL state. Signed-off-by: Arik Hadas --- .../core/bll/storage/disk/image/RemoveImageCommand.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveImageCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveImageCommand.java index de2d0168bfb..a08219453cf 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveImageCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveImageCommand.java @@ -138,12 +138,14 @@ protected void executeCommand() { if (e.getErrorCode() == EngineError.ImageDoesNotExistInDomainError) { log.info("Disk '{}' doesn't exist on storage domain '{}', rolling forward", getDiskImage().getId(), getStorageDomainId()); + endSuccessfully(); } else if (e.getErrorCode() == EngineError.ImageDeleteError && isImageRemovedFromStorage()) { // VDSM renames the image before deleting it, so technically the image doesn't exist after renaming, // but the actual delete can still fail with ImageDeleteError. // In this case, Engine has to check whether image still exists on the storage or not. - log.info("Disk '{}' was deleted from storage domain '{}'", getDiskImage().getId(), - getStorageDomainId()); + log.info("Failed to delete Disk '{}' from storage domain '{}', changing to illegal", + getDiskImage().getId(), getStorageDomainId()); + endWithFailure(); } else { throw e; }