Pearl1594 commented on code in PR #12617:
URL: https://github.com/apache/cloudstack/pull/12617#discussion_r3382789400


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -3320,6 +3334,29 @@ protected void migrate(final VMInstanceVO vm, final long 
srcHostId, final Deploy
         }
     }
 
+    private void executePostMigrationCommand(VMInstanceVO vm, VirtualMachineTO 
to, long dstHostId) {
+        if (vm.getHypervisorType() == HypervisorType.KVM && 
hasClvmVolumes(vm.getId())) {
+            try {
+                logger.info("Executing post-migration tasks for VM {} with 
CLVM volumes on destination host {}", vm.getInstanceName(), dstHostId);
+                final PostMigrationCommand postMigrationCommand = new 
PostMigrationCommand(to, vm.getInstanceName());
+                final Answer postMigrationAnswer = _agentMgr.send(dstHostId, 
postMigrationCommand);
+
+                if (postMigrationAnswer == null || 
!postMigrationAnswer.getResult()) {
+                    final String details = postMigrationAnswer != null ? 
postMigrationAnswer.getDetails() : "null answer returned";
+                    logger.warn("Post-migration tasks failed for VM {} on 
destination host {}: {}. Migration completed but some cleanup may be needed.",
+                            vm.getInstanceName(), dstHostId, details);
+                } else {
+                    logger.info("Successfully completed post-migration tasks 
for VM {} on destination host {}", vm.getInstanceName(), dstHostId);
+                }
+            } catch (Exception e) {
+                logger.warn("Exception during post-migration tasks for VM {} 
on destination host {}: {}. Migration completed but some cleanup may be 
needed.",
+                        vm.getInstanceName(), dstHostId, e.getMessage(), e);
+            }
+        }
+
+        updateClvmLockHostForVmVolumes(vm.getId(), dstHostId);

Review Comment:
   if it does, in the next re-try it will get corrected.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to