From 8b0ca887ea76fdafa9999acc78b0a9504e8ffd5d 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 would be removed from the database (rather than staying in LOCKED state) and the command would finish successfully in the first case, and would end with failure with the image switching to ILLEGAL state in the second case. 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; }