Eli Mesika has uploaded a new change for review. Change subject: core: task manager cache is not cleared..(#854308) ......................................................................
core: task manager cache is not cleared..(#854308) task manager cache is not cleared after getting error that task does not exist from vdsm on stopTask(#854308) This patch insures that async tasks found in engine and not found by VDSM will get the 'unknown' state. The case in which there may be no SPM temporally as a result of a failure is handled differently in AsyncTaskManager and SPMGetAllTasksStatusesVDSCommand. Previous code sets all tasks that are found by engine (in cache) and not found as VDSM as running. This prevented cleanup of unknown tasks from the cache as described in BZ. https://bugzilla.redhat.com/854308 Change-Id: I979cb7d2273c2eaaa2866dcb4a5f760f9266e11e Signed-off-by: Eli Mesika <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SPMAsyncTask.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/SPMGetAllTasksStatusesVDSCommand.java 3 files changed, 15 insertions(+), 19 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/8161/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java index 16efca4..2b154ab 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java @@ -288,10 +288,13 @@ // For each pool Id (SPM) ,add its tasks to the map. for (Guid storagePoolID : poolsOfActiveTasks) { try { - poolsAsyncTaskMap.put(storagePoolID, new HashMap<Guid, AsyncTaskStatus>( + Map<Guid, AsyncTaskStatus> map = (Map<Guid, AsyncTaskStatus>) Backend.getInstance().getResourceManager().RunVdsCommand( VDSCommandType.SPMGetAllTasksStatuses, - new IrsBaseVDSCommandParameters(storagePoolID)).getReturnValue())); + new IrsBaseVDSCommandParameters(storagePoolID)).getReturnValue(); + if (map != null) { + poolsAsyncTaskMap.put(storagePoolID, map); + } } catch (RuntimeException e) { if ((e instanceof VdcBLLException) && (((VdcBLLException) e).getErrorCode() == VdcBllErrors.VDS_NETWORK_ERROR)) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SPMAsyncTask.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SPMAsyncTask.java index a7f0bb3..b50560b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SPMAsyncTask.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SPMAsyncTask.java @@ -307,14 +307,8 @@ /** * Print log message, Checks if the cachedStatusTask is null, (indicating the task was not found in the SPM). - * If so returns {@link AsyncTaskStatusEnum#running} status, otherwise returns the status as given.<br> + * If so returns {@link AsyncTaskStatusEnum#unknown} status, otherwise returns the status as given.<br> * <br> - * <b>Note:</b> The task is returned as running since we need to support a case where there is a change of SPM, - * or the SPM is just recovering from crash, and the SPM might return that it doesn't know that this task exists, - * but in actuality it exists. If in this case {@link AsyncTaskStatusEnum#unknown} is returned then the task - * will become a permanent zombie task since it won't be polled, so take notice if you ever want to change this - * behavior. - * * @param cachedStatusTask The status from the SPM, or <code>null</code> is the task wasn't found in the SPM. * @return - Updated status task */ @@ -324,14 +318,12 @@ // If the cachedStatusTask is null ,that means the task has not been found in the SPM. if (cachedStatusTask == null) { // Set to running in order to continue polling the task in case SPM hasn't loaded the tasks yet.. - returnedStatusTask = new AsyncTaskStatus(AsyncTaskStatusEnum.running); + returnedStatusTask = new AsyncTaskStatus(AsyncTaskStatusEnum.unknown); - if (getLastTaskStatus().getStatus() != returnedStatusTask.getStatus()) { - log.errorFormat("SPMAsyncTask::PollTask: Task '{0}' (Parent Command {1}, Parameters Type {2}) " + - "was not found in VDSM, will change its status to running.", + log.errorFormat("SPMAsyncTask::PollTask: Task '{0}' (Parent Command {1}, Parameters Type {2}) " + + "was not found in VDSM, will change its status to unknown.", getTaskID(), (getParameters().getDbAsyncTask().getaction_type()), getParameters().getClass().getName()); - } } else { returnedStatusTask = cachedStatusTask; } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/SPMGetAllTasksStatusesVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/SPMGetAllTasksStatusesVDSCommand.java index e550c67..11e6e15 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/SPMGetAllTasksStatusesVDSCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/SPMGetAllTasksStatusesVDSCommand.java @@ -1,11 +1,12 @@ package org.ovirt.engine.core.vdsbroker.irsbroker; -import org.ovirt.engine.core.compat.*; -import org.ovirt.engine.core.common.businessentities.*; +import org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.utils.log.Logged; import org.ovirt.engine.core.utils.log.Logged.LogLevel; -import org.ovirt.engine.core.vdsbroker.*; -import org.ovirt.engine.core.common.vdscommands.*; +import org.ovirt.engine.core.vdsbroker.ResourceManager; @Logged(executionLevel = LogLevel.DEBUG) public class SPMGetAllTasksStatusesVDSCommand<P extends IrsBaseVDSCommandParameters> extends IrsBrokerCommand<P> { @@ -16,7 +17,7 @@ @Override protected void ExecuteIrsBrokerCommand() { if (getCurrentIrsProxyData().getCurrentVdsId().equals(Guid.Empty)) { - setReturnValue(new java.util.HashMap<Guid, AsyncTaskStatus>()); + setReturnValue(null); } else { setVDSReturnValue(ResourceManager.getInstance().runVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, new VdsIdVDSCommandParametersBase(getCurrentIrsProxyData().getCurrentVdsId()))); -- To view, visit http://gerrit.ovirt.org/8161 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I979cb7d2273c2eaaa2866dcb4a5f760f9266e11e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
