Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adding parameters to the message for the MERGE_SNAPSHOTS step in the disk migration operation #953

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}