Skip to content

Commit

Permalink
This commit fixes the following issue: During the disk migration oper…
Browse files Browse the repository at this point in the history
…ation, when the VM is turned on, the message is displayed in the list of tasks to be performed: Merging snapshots (UNKNOWN into UNKNOWN) of disk UNKNOWN.

Now the correct values are displayed instead of UNKNOWN.

Signed-off-by: Evgeniy Kononov <EKononov@rockitsoft.ru>
  • Loading branch information
ekononov committed Jun 25, 2024
1 parent 1043c13 commit e76da96
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.ovirt.engine.core.dao.DiskImageDynamicDao;
import org.ovirt.engine.core.dao.ImageDao;
import org.ovirt.engine.core.dao.ImageStorageDomainMapDao;
import org.ovirt.engine.core.dao.SnapshotDao;
import org.ovirt.engine.core.dao.StorageDomainDao;
import org.ovirt.engine.core.dao.StorageDomainStaticDao;
import org.ovirt.engine.core.dao.VmDao;
Expand Down Expand Up @@ -128,6 +129,8 @@ public class LiveMigrateDiskCommand<T extends LiveMigrateDiskParameters> extends
@Inject
@Typed(SerialChildCommandsExecutionCallback.class)
private Instance<SerialChildCommandsExecutionCallback> callbackProvider;
@Inject
private SnapshotDao snapshotDao;

private Map<Guid, DiskImage> diskImagesMap = new HashMap<>();

Expand Down Expand Up @@ -252,7 +255,8 @@ public boolean performNextOperation(int completedChildCount) {
if (getParameters().getLiveDiskMigrateStage() == LiveDiskMigrateStage.CREATE_SNAPSHOT) {
runInternalAction(ActionType.CloneImageGroupVolumesStructure,
buildCloneImageGroupVolumesStructureCommandParams(),
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.CLONE_IMAGE_STRUCTURE)));
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.CLONE_IMAGE_STRUCTURE,
Collections.emptyMap())));
updateStage(LiveDiskMigrateStage.CLONE_IMAGE_STRUCTURE);
return true;
}
Expand Down Expand Up @@ -301,7 +305,8 @@ public boolean performNextOperation(int completedChildCount) {

updateStage(LiveDiskMigrateStage.AUTO_GENERATED_SNAPSHOT_REMOVE_START);
CommandContext commandContext =
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.MERGE_SNAPSHOTS));
ExecutionHandler.createInternalJobContext(createStepsContext(StepEnum.MERGE_SNAPSHOTS,
getMergeSnapshotsJobMessageProperties()));
removeAutogeneratedSnapshot(commandContext, getActionType(), getParameters());
updateStage(LiveDiskMigrateStage.AUTO_GENERATED_SNAPSHOT_REMOVE_END);

Expand Down Expand Up @@ -348,11 +353,11 @@ private void removeAutogeneratedSnapshot(CommandContext commandContext, ActionTy
commandContext);
}

private CommandContext createStepsContext(StepEnum step) {
private CommandContext createStepsContext(StepEnum step, Map<String, String> jobMessageProperties) {
Step addedStep = executionHandler.addSubStep(getExecutionContext(),
getExecutionContext().getJob().getStep(StepEnum.EXECUTING),
step,
ExecutionMessageDirector.resolveStepMessage(step, Collections.emptyMap()));
ExecutionMessageDirector.resolveStepMessage(step, jobMessageProperties));
ExecutionContext ctx = new ExecutionContext();
ctx.setStep(addedStep);
ctx.setMonitored(true);
Expand Down Expand Up @@ -551,7 +556,8 @@ private void syncImageData() {
parameters.setLive(true);
}

runInternalAction(ActionType.CopyImageGroupVolumesData, parameters, createStepsContext(StepEnum.SYNC_IMAGE_DATA));
runInternalAction(ActionType.CopyImageGroupVolumesData, parameters, createStepsContext(StepEnum.SYNC_IMAGE_DATA,
Collections.emptyMap()));
}

private void replicateDiskStart() {
Expand Down Expand Up @@ -824,4 +830,19 @@ public Map<String, String> getJobMessageProperties() {
}
return jobProperties;
}

private Map<String, String> getMergeSnapshotsJobMessageProperties() {
DiskImage diskImage = diskImageDao.getSnapshotById(getParameters().getImageId());
DiskImage destDiskImage = diskImageDao.getSnapshotById(getParameters().getDestinationImageId());

Map<String, String> jobMessageProperties = new HashMap<>();
jobMessageProperties.put(VdcObjectType.Disk.name().toLowerCase(), diskImage.getDiskAlias());
jobMessageProperties.put("sourcesnapshot",
Optional.ofNullable(snapshotDao.get(diskImage.getVmSnapshotId()).getDescription()).orElse(""));
jobMessageProperties.put("destinationsnapshot",
Optional.ofNullable(snapshotDao.get(destDiskImage.getVmSnapshotId()).getDescription()).orElse(""));

return jobMessageProperties;
}

}

0 comments on commit e76da96

Please sign in to comment.