use of org.ovirt.engine.core.common.action.MergeStatusReturnValue in project ovirt-engine by oVirt.
the class DestroyImageCommand method executeCommand.
@Override
protected void executeCommand() {
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId()));
VDSReturnValue vdsReturnValue = null;
try {
vdsReturnValue = runVdsCommand(VDSCommandType.DestroyImage, createVDSParameters());
} catch (EngineException e) {
log.error("Failed to delete image {}/{}", getParameters().getImageGroupId(), getParameters().getImageList().stream().findFirst().get(), e);
if (!getParameters().isLiveMerge()) {
throw e;
}
}
if (vdsReturnValue != null && vdsReturnValue.getCreationInfo() != null) {
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
Guid result = createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId());
getTaskIdList().add(result);
log.info("Successfully started task to remove orphaned volumes resulting from live merge");
} else {
log.info("Retrying deleting image {}/{}", getParameters().getImageGroupId(), getParameters().getImageList().stream().findFirst().get());
MergeStatusReturnValue returnValue = new MergeStatusReturnValue(VmBlockJobType.COMMIT, new HashSet<>(getParameters().getImageList()));
getReturnValue().setActionReturnValue(returnValue);
// At this point, we know that this command was executed during live merge and it is safe to do
// the casting in the next line.
((RemoveSnapshotSingleDiskParameters) getParameters().getParentParameters()).setNextCommandStep(RemoveSnapshotSingleDiskStep.DESTROY_IMAGE);
}
setSucceeded(true);
setCommandStatus(CommandStatus.SUCCEEDED);
}
use of org.ovirt.engine.core.common.action.MergeStatusReturnValue in project ovirt-engine by oVirt.
the class MergeStatusCommand method attemptResolution.
public void attemptResolution() {
Set<Guid> images;
if (vmDynamicDao.get(getParameters().getVmId()).getStatus().isNotRunning()) {
StoragePool pool = storagePoolDao.get(getParameters().getStoragePoolId());
if (pool.getSpmVdsId() == null || pool.getStatus() != StoragePoolStatus.Up) {
log.info("VM down, waiting on SPM election to resolve Live Merge");
setSucceeded(true);
return;
} else {
log.error("VM is not running, proceeding with Live Merge recovery");
images = getVolumeChainFromRecovery();
}
} else {
images = getVolumeChain();
}
if (images == null || images.isEmpty()) {
log.error("Failed to retrieve images list of VM {}. Retrying ...", getParameters().getVmId());
setCommandStatus(CommandStatus.SUCCEEDED);
setSucceeded(true);
// As this command is executed only during live merge flow, the following casting is safe.
((RemoveSnapshotSingleDiskParameters) getParameters().getParentParameters()).setNextCommandStep(RemoveSnapshotSingleDiskStep.MERGE_STATUS);
return;
}
Set<Guid> imagesToRemove = getImagesToRemove();
images.retainAll(imagesToRemove);
if (images.size() != 1) {
log.error("Failed to live merge, still in volume chain: {}", images);
setCommandStatus(CommandStatus.FAILED);
return;
}
if (!images.contains(getParameters().getBaseImage().getImageId())) {
// If the base image isn't found in qemu chain, it means that the image was already deleted.
// In this case, we will not allow PULL merge but rather ask the user to check if the parent
// snapshot contains illegal volume(s). If so, that snapshot must be deleted before deleting
// other snapshots
addCustomValue("SnapshotName", snapshotDao.get(getParameters().getBaseImage().getSnapshotId()).getDescription());
addCustomValue("BaseVolumeId", getParameters().getBaseImage().getImageId().toString());
auditLog(this, AuditLogType.USER_REMOVE_SNAPSHOT_FINISHED_FAILURE_BASE_IMAGE_NOT_FOUND);
setCommandStatus(CommandStatus.FAILED);
return;
}
imagesToRemove.removeAll(images);
log.info("Successfully removed volume(s): {}", imagesToRemove);
// For now, only COMMIT type is supported
log.info("Volume merge type '{}'", VmBlockJobType.COMMIT.name());
MergeStatusReturnValue returnValue = new MergeStatusReturnValue(VmBlockJobType.COMMIT, imagesToRemove);
getReturnValue().setActionReturnValue(returnValue);
setSucceeded(true);
persistCommand(getParameters().getParentCommand(), true);
setCommandStatus(CommandStatus.SUCCEEDED);
}
Aggregations