abh1sar commented on code in PR #12062:
URL: https://github.com/apache/cloudstack/pull/12062#discussion_r2681382733
##########
server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java:
##########
@@ -456,6 +449,31 @@ public DeployDestination
planDeployment(VirtualMachineProfile vmProfile, Deploym
return dest;
}
+ private Host checkDeployInVmLastHost(VirtualMachineProfile vmProfile,
VirtualMachine vm) {
+ String considerLastHostStr =
(String)vmProfile.getParameter(VirtualMachineProfile.Param.ConsiderLastHost);
+ String haVmTag =
(String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
+ boolean considerLastHost = vm.getLastHostId() != null && haVmTag ==
null &&
+ (considerLastHostStr == null ||
Boolean.TRUE.toString().equalsIgnoreCase(considerLastHostStr));
+ if (!considerLastHost) {
+ return null;
+ }
+
+ logger.debug("This VM has last host_id: {}", vm.getLastHostId());
+ HostVO lastHost = _hostDao.findById(vm.getLastHostId());
+ if (lastHost == null) {
+ logger.debug("Unable to deploy VM {} in the last host, last host
doesn't exist", vm.getName());
+ return null;
+ }
+
+ logger.debug("VM's last host is {}, trying to choose the same host if
it is not in maintenance, error or degraded state", lastHost);
+ if (lastHost.isInMaintenanceStates() ||
Arrays.asList(ResourceState.Error,
ResourceState.Degraded).contains(lastHost.getResourceState())) {
+ logger.debug("Unable to deploy VM {} in the last host, last host
{} is in {} state", vm.getName(), lastHost.getName(),
lastHost.getResourceState());
+ return null;
+ }
+
Review Comment:
deployInVmLastHost -> canUseLastHost already has host specific checks.
host null check is already present.
can we move the maintenance mode check also there?
##########
server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java:
##########
@@ -456,6 +449,31 @@ public DeployDestination
planDeployment(VirtualMachineProfile vmProfile, Deploym
return dest;
}
+ private Host checkDeployInVmLastHost(VirtualMachineProfile vmProfile,
VirtualMachine vm) {
+ String considerLastHostStr =
(String)vmProfile.getParameter(VirtualMachineProfile.Param.ConsiderLastHost);
+ String haVmTag =
(String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
+ boolean considerLastHost = vm.getLastHostId() != null && haVmTag ==
null &&
+ (considerLastHostStr == null ||
Boolean.TRUE.toString().equalsIgnoreCase(considerLastHostStr));
Review Comment:
I know it's old code, but just to make it clearer
```suggestion
!Boolean.FALSE.toString().equalsIgnoreCase(considerLastHostStr));
```
--
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]