From e76da962609790d3b2fe52820c171786efdad42a Mon Sep 17 00:00:00 2001 From: ekononov Date: Fri, 21 Jun 2024 18:09:11 +0300 Subject: [PATCH] This commit fixes the following issue: During the disk migration operation, 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 --- .../storage/lsm/LiveMigrateDiskCommand.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/lsm/LiveMigrateDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/lsm/LiveMigrateDiskCommand.java index 6faed984173..884451bc2d7 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/lsm/LiveMigrateDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/lsm/LiveMigrateDiskCommand.java @@ -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; @@ -128,6 +129,8 @@ public class LiveMigrateDiskCommand extends @Inject @Typed(SerialChildCommandsExecutionCallback.class) private Instance callbackProvider; + @Inject + private SnapshotDao snapshotDao; private Map diskImagesMap = new HashMap<>(); @@ -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; } @@ -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); @@ -348,11 +353,11 @@ private void removeAutogeneratedSnapshot(CommandContext commandContext, ActionTy commandContext); } - private CommandContext createStepsContext(StepEnum step) { + private CommandContext createStepsContext(StepEnum step, Map 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); @@ -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() { @@ -824,4 +830,19 @@ public Map getJobMessageProperties() { } return jobProperties; } + + private Map getMergeSnapshotsJobMessageProperties() { + DiskImage diskImage = diskImageDao.getSnapshotById(getParameters().getImageId()); + DiskImage destDiskImage = diskImageDao.getSnapshotById(getParameters().getDestinationImageId()); + + Map 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; + } + }