-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Deployment plan fixes for VM with last host, and last host in maintenance #12062
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
Open
sureshanaparti
wants to merge
4
commits into
apache:4.20
Choose a base branch
from
shapeblue:vm-deployment-with-last-host-improvements
base: 4.20
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+30
−15
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -378,16 +378,8 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym | |
| planner = getDeploymentPlannerByName(plannerName); | ||
| } | ||
|
|
||
| Host lastHost = null; | ||
|
|
||
| String considerLastHostStr = (String)vmProfile.getParameter(VirtualMachineProfile.Param.ConsiderLastHost); | ||
| boolean considerLastHost = vm.getLastHostId() != null && haVmTag == null && | ||
| (considerLastHostStr == null || Boolean.TRUE.toString().equalsIgnoreCase(considerLastHostStr)); | ||
| if (considerLastHost) { | ||
| HostVO host = _hostDao.findById(vm.getLastHostId()); | ||
| logger.debug("This VM has last host_id specified, trying to choose the same host: " + host); | ||
| lastHost = host; | ||
|
|
||
| Host lastHost = checkDeployInVmLastHost(vmProfile, vm); | ||
| if (lastHost != null) { | ||
| DeployDestination deployDestination = deployInVmLastHost(vmProfile, plan, avoids, planner, vm, dc, offering, cpuRequested, ramRequested, volumesRequireEncryption); | ||
| if (deployDestination != null) { | ||
| return deployDestination; | ||
|
|
@@ -456,6 +448,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 state", lastHost); | ||
| if (lastHost.isInMaintenanceStates()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably checking other states as well? Or migrating only to enabled and running hosts? |
||
| logger.debug("Unable to deploy VM {} in the last host, last host {} is in maintenance state", vm.getName(), lastHost.getName()); | ||
| return null; | ||
| } | ||
|
|
||
| return lastHost; | ||
| } | ||
|
|
||
| private void avoidDifferentArchResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) { | ||
| VirtualMachineTemplate template = vmProfile.getTemplate(); | ||
| for (CPU.CPUArch arch : clusterArchTypes) { | ||
|
|
@@ -1474,7 +1491,7 @@ private Pair<Boolean, Boolean> findVMStorageRequirements(VirtualMachineProfile v | |
|
|
||
| protected Pair<Host, Map<Volume, StoragePool>> findPotentialDeploymentResources(List<Host> suitableHosts, Map<Volume, List<StoragePool>> suitableVolumeStoragePools, | ||
| ExcludeList avoid, PlannerResourceUsage resourceUsageRequired, List<Volume> readyAndReusedVolumes, List<Long> preferredHosts, VirtualMachine vm) { | ||
| logger.debug("Trying to find a potenial host and associated storage pools from the suitable host/pool lists for this VM"); | ||
| logger.debug("Trying to find a potential host and associated storage pools from the suitable host/pool lists for this VM"); | ||
|
|
||
| boolean hostCanAccessPool = false; | ||
| boolean haveEnoughSpace = false; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sureshanaparti I'm not clear why the first part of this OR operator would make it consider the last host. I would assume if the ConsiderLastHost parameter is not set that this evaluates to false?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nvazquez , true is the documented default, so we should treat null as true. (if it is not passed in the parameters, I actually do not know if that would be handled upstream already)