Ravi Nori has uploaded a new change for review. Change subject: engine : CommandBase should not set end status for commands with callback ......................................................................
engine : CommandBase should not set end status for commands with callback When mixing async tasks and async commands if a callback is provided by the command the CommandBase should not set the status of the command. The command should override endSuccessfully and endWithFailure to set the status of the async tasks status to succeeded or failed. Change-Id: I84c05917003376d2f62d3da7acecd889f8cb79e0 Bug-Url: https://bugzilla.redhat.com/1160872 Signed-off-by: Ravi Nori <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotSingleDiskLiveCommand.java 2 files changed, 39 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/35232/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java index 4766502..ab37b88 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java @@ -563,10 +563,14 @@ boolean exceptionOccurred = false; try { if (isEndSuccessfully()) { - setCommandStatus(CommandStatus.SUCCEEDED); + if (getCallBack() == null) { + setCommandStatus(CommandStatus.SUCCEEDED); + } internalEndSuccessfully(); } else { - setCommandStatus(CommandStatus.FAILED); + if (getCallBack() == null) { + setCommandStatus(CommandStatus.FAILED); + } internalEndWithFailure(); } } catch (RuntimeException e) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotSingleDiskLiveCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotSingleDiskLiveCommand.java index e028600..87a51ee 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotSingleDiskLiveCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotSingleDiskLiveCommand.java @@ -344,7 +344,20 @@ @Override protected void endSuccessfully() { - setSucceeded(true); + if (getParameters().getCommandStep() == RemoveSnapshotSingleDiskLiveStep.DESTROY_IMAGE) { + Guid currentChildId = getParameters().getChildCommands().get( + getParameters().getCommandStep()); + if (!Guid.isNullOrEmpty(currentChildId)) { + CommandBase<?> command = CommandCoordinatorUtil.retrieveCommand(currentChildId); + if (command != null) { + Backend.getInstance().endAction(VdcActionType.DestroyImage, + command.getParameters(), + cloneContextAndDetachFromParent()); + } + } + } else { + setSucceeded(true); + } } public void onFailed() { @@ -384,6 +397,25 @@ } @Override + protected void endWithFailure() { + if (getParameters().getCommandStep() == RemoveSnapshotSingleDiskLiveStep.DESTROY_IMAGE) { + Guid currentChildId = getParameters().getChildCommands().get( + getParameters().getCommandStep()); + if (!Guid.isNullOrEmpty(currentChildId)) { + CommandBase<?> command = CommandCoordinatorUtil.retrieveCommand(currentChildId); + if (command != null) { + command.getParameters().setTaskGroupSuccess(false); + Backend.getInstance().endAction(VdcActionType.DestroyImage, + command.getParameters(), + cloneContextAndDetachFromParent()); + } + } + } else { + setSucceeded(true); + } + } + + @Override public CommandCallBack getCallBack() { return new RemoveSnapshotSingleDiskLiveCommandCallback(); } -- To view, visit http://gerrit.ovirt.org/35232 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I84c05917003376d2f62d3da7acecd889f8cb79e0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
