From 830bba7492ebce04c7ff90cd7f24f9e3e80a1b35 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Wed, 2 Nov 2022 21:46:19 +0200 Subject: [PATCH] core: fix monitoring of RemoveVm Previously, RemoveVm and RemoveAllVmImages didn't have a callback so they didn't wait for all instances of RemoveImage to finish before finishing RemoveVm and therefore the job of RemoveVm may have been completed while the images are still locked in the database. Now, RemoveVm is completed after RemoveImage completes and the images are removed from the database. Signed-off-by: Arik Hadas --- .../java/org/ovirt/engine/core/bll/RemoveVmCommand.java | 2 +- .../bll/storage/disk/image/RemoveAllVmImagesCommand.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java index cb9ee845d2a..2025fc0f03c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java @@ -526,6 +526,6 @@ public Guid createTask(Guid taskId, @Override public CommandCallback getCallback() { - return getParameters().isUseCinderCommandCallback() ? callbackProvider.get() : null; + return callbackProvider.get(); } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveAllVmImagesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveAllVmImagesCommand.java index 2466a3bdaca..5b4c8929580 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveAllVmImagesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveAllVmImagesCommand.java @@ -9,12 +9,15 @@ import java.util.List; import java.util.Set; +import javax.enterprise.inject.Instance; import javax.inject.Inject; +import org.ovirt.engine.core.bll.ConcurrentChildCommandsExecutionCallback; import org.ovirt.engine.core.bll.InternalCommandAttribute; import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute; import org.ovirt.engine.core.bll.VmCommand; import org.ovirt.engine.core.bll.context.CommandContext; +import org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback; import org.ovirt.engine.core.common.action.ActionReturnValue; import org.ovirt.engine.core.common.action.ActionType; import org.ovirt.engine.core.common.action.RemoveAllVmImagesParameters; @@ -47,6 +50,8 @@ public class RemoveAllVmImagesCommand ext private DiskImageDao diskImageDao; @Inject private ImageDao imageDao; + @Inject + private Instance callbackProvider; public RemoveAllVmImagesCommand(T parameters, CommandContext cmdContext) { super(parameters, cmdContext); @@ -142,4 +147,8 @@ protected void endVmCommand() { super.endVmCommand(); } } + + public CommandCallback getCallback() { + return callbackProvider.get(); + } }