vishesh92 commented on code in PR #14108:
URL: https://github.com/apache/cloudstack/pull/14108#discussion_r3988312220
##########
server/src/main/java/org/apache/cloudstack/cluster/ClusterDrsServiceImpl.java:
##########
@@ -783,23 +850,51 @@ void executeDrsPlan(ClusterDrsPlanVO plan) {
plan.setStatus(ClusterDrsPlan.Status.IN_PROGRESS);
drsPlanDao.update(plan.getId(), plan);
+ // a queued migration occupies both ends until it completes, and it
may not complete at all
+ List<VirtualMachine> dispatched = new ArrayList<>();
+ List<Long> dispatchedSourceHosts = new ArrayList<>();
+
for (ClusterDrsPlanMigrationVO migration : planMigrations) {
try {
- VirtualMachine vm =
vmInstanceDao.findById(migration.getVmId());
+ VMInstanceVO vm = vmInstanceDao.findById(migration.getVmId());
Host host = hostDao.findById(migration.getDestHostId());
if (vm == null || host == null) {
throw new CloudRuntimeException(String.format("vm %s or
host %s is not found", migration.getVmId(),
migration.getDestHostId()));
}
+ if (destinationViolatesAffinity(vm, host, dispatched,
dispatchedSourceHosts)) {
+ String reason = String.format("Skipped DRS migration of %s
to %s: the destination no longer "
+ + "satisfies the placement rules for that VM. The
plan was generated against older "
+ + "state.", vm, host);
+ logger.warn(reason);
+ // cancelled rather than failed: nothing went wrong, the
plan went out of date
+ migration.setStatus(JobInfo.Status.CANCELLED);
+ drsPlanMigrationDao.update(migration.getId(), migration);
+ ActionEventUtils.onCompletedActionEvent(User.UID_SYSTEM,
Account.ACCOUNT_ID_SYSTEM,
+ EventVO.LEVEL_WARN, EventTypes.EVENT_CLUSTER_DRS,
false, reason,
Review Comment:
```suggestion
EventVO.LEVEL_WARN,
EventTypes.EVENT_CLUSTER_DRS, true, reason,
```
this is to ensure the event is displayed under the cluster's events.
--
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]