-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: RemoveImage: handle failure in VDS command
RemoveImageCommand used to call for DeleteImageGroup VDS command, and perform the required DB operations without polling on the Async Task. One issue that it led to is when disk is configured with "Wipe on Delete", and the wipe action took more than 50 hours (default max async task polling time) - the task was interrupted, the image is not deleted in VDSM, but removed from DB, not having any tracking for them in the engine. In this patch we add async task polling to RemoveImageCommand and handle the issue with interrupted wipe on delete. Bug-Url: https://bugzilla.redhat.com/1836318
- Loading branch information
Showing
2 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...rc/main/java/org/ovirt/engine/core/bll/storage/disk/image/RemoveImageCommandCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.ovirt.engine.core.bll.storage.disk.image; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import javax.enterprise.inject.Typed; | ||
import javax.inject.Inject; | ||
|
||
import org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil; | ||
import org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback; | ||
import org.ovirt.engine.core.common.action.RemoveImageParameters; | ||
import org.ovirt.engine.core.common.businessentities.AsyncTaskStatus; | ||
import org.ovirt.engine.core.compat.CommandStatus; | ||
import org.ovirt.engine.core.compat.Guid; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@Typed(RemoveImageCommandCallback.class) | ||
public class RemoveImageCommandCallback implements CommandCallback { | ||
private static final Logger log = LoggerFactory.getLogger(RemoveImageCommandCallback.class); | ||
|
||
@Inject | ||
private CommandCoordinatorUtil commandCoordinatorUtil; | ||
|
||
@Override | ||
public void doPolling(Guid cmdId, List<Guid> childCmdIds) { | ||
RemoveImageCommand<RemoveImageParameters> command = getRemoveImageCommand(cmdId); | ||
Set<Guid> taskIds = new HashSet<>(command.getReturnValue().getVdsmTaskIdList()); | ||
Map<Guid, AsyncTaskStatus> idToTaskStatusMap = commandCoordinatorUtil.pollTasks(taskIds); | ||
for (Map.Entry<Guid, AsyncTaskStatus> idToTaskStatus : idToTaskStatusMap.entrySet()) { | ||
Guid id = idToTaskStatus.getKey(); | ||
AsyncTaskStatus status = idToTaskStatus.getValue(); | ||
if (status.getTaskIsRunning()) { | ||
log.info("Waiting on remove image command to complete the task (taskId = '{}')", id); | ||
return; | ||
} | ||
} | ||
|
||
List<AsyncTaskStatus> failedTasks = new ArrayList<>(); | ||
idToTaskStatusMap.forEach((id, status) -> { | ||
if (!status.getTaskEndedSuccessfully()) { | ||
failedTasks.add(status); | ||
} | ||
}); | ||
if (failedTasks.isEmpty()) { | ||
command.setSucceeded(true); | ||
command.setCommandStatus(CommandStatus.SUCCEEDED); | ||
command.persistCommand(command.getParameters().getParentCommand()); | ||
log.info("Remove image command has completed successfully for image '{}' with async task '{}'.", | ||
command.getParameters().getImageId(), taskIds); | ||
} else { | ||
command.setSucceeded(false); | ||
command.setCommandStatus(CommandStatus.FAILED); | ||
log.info("Remove image command has failed for images '{}' with async task '{}'.", | ||
command.getParameters().getImageId(), failedTasks); | ||
} | ||
command.persistCommand(command.getParameters().getParentCommand()); | ||
} | ||
|
||
@Override | ||
public void onSucceeded(Guid cmdId, List<Guid> childCmdIds) { | ||
getRemoveImageCommand(cmdId).onSucceeded(); | ||
} | ||
|
||
@Override | ||
public void onFailed(Guid cmdId, List<Guid> childCmdIds) { | ||
getRemoveImageCommand(cmdId).onFailed(); | ||
} | ||
|
||
private RemoveImageCommand<RemoveImageParameters> getRemoveImageCommand(Guid cmdId) { | ||
return commandCoordinatorUtil.retrieveCommand(cmdId); | ||
} | ||
} |