Skip to content
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

Allow setting virtual NUMA nodes without host pinning #402

Merged
merged 1 commit into from Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -330,7 +330,7 @@ public ValidationResult checkVmNumaNodesIntegrity(final VM vm, final List<VmNuma
}

// Check if the VM is pinned to at least one host
if (vm.getDedicatedVmForVdsList().isEmpty() && !VmCpuCountHelper.isResizeAndPinPolicy(vm)) {
if (vm.getDedicatedVmForVdsList().isEmpty() && !VmCpuCountHelper.isResizeAndPinPolicy(vm) && isNumaPinning(vmNumaNodes)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_PINNED_TO_AT_LEAST_ONE_HOST);
}
liranr23 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -346,6 +346,10 @@ public ValidationResult checkVmNumaNodesIntegrity(final VM vm, final List<VmNuma
return validateNumaCompatibility(vm, vmNumaNodes, hostsNumaNodesMap);
}

private boolean isNumaPinning(final List<VmNumaNode> vmNumaNodes) {
return vmNumaNodes.stream().anyMatch(node -> !node.getVdsNumaNodeList().isEmpty());
}

private String formatMissingIndices(List<Integer> missingIndices) {
String str = StringUtils.join(missingIndices.subList(0, min(10, missingIndices.size())), ", ");
if (missingIndices.size() > 10) {
Expand Down
Expand Up @@ -100,13 +100,12 @@ public void validateWithPinnedHostOnVm() {
}

@Test
public void canNotDoWithoutPinnedHost() {
public void canDoWithoutPinnedHost() {
mockCommandWithVmFromDb();
vm.setMigrationSupport(MigrationSupport.IMPLICITLY_NON_MIGRATABLE);

vm.setDedicatedVmForVdsList(new ArrayList<>());
ValidateTestUtils.runAndAssertValidateFailure(command,
EngineMessage.ACTION_TYPE_FAILED_VM_NOT_PINNED_TO_AT_LEAST_ONE_HOST);
assertThat(command.validate()).isTrue();
}

@Test
Expand Down
Expand Up @@ -1707,6 +1707,7 @@ public void edit(UnitVmModel model) {
affinityGroupSelectionWidget.init(model.getAffinityGroupList());
affinityLabelSelectionWidget.init(model.getLabelList());
quotaEditor.setEnabled(!model.isHostedEngine());
numaNodeCount.setEnabled(true);
initTabAvailabilityListeners(model);
initListeners(model);
hideAlwaysHiddenFields();
Expand Down Expand Up @@ -1755,7 +1756,6 @@ private void setNumaInfoMsg(String message) {
}

private void enableNumaFields(boolean enabled) {
numaNodeCount.setEnabled(enabled);
numaSupportButton.setEnabled(enabled);
ljelinkova marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
Expand Up @@ -501,7 +501,7 @@ protected VM getVmWithNuma() {
protected void updateNumaEnabled() {
super.updateNumaEnabled();
updateNumaEnabledHelper();
if (Boolean.TRUE.equals(getModel().getNumaEnabled().getEntity()) && getModel().getVmNumaNodes() != null) {
if (getModel().getVmNumaNodes() != null) {
getModel().getNumaNodeCount().setEntity(getModel().getVmNumaNodes().size());
}

Expand Down
Expand Up @@ -1641,15 +1641,14 @@ protected final void updateNumaEnabledHelper() {

if (getModel().getIsAutoAssign().getEntity() ||
getModel().getDefaultHost().getSelectedItems() == null ||
getModel().getDefaultHost().getSelectedItems().isEmpty() ||
getModel().getDefaultHost().getSelectedItems().stream().anyMatch(x -> !x.isNumaSupport())) {
enabled = false;
}
if (enabled) {
getModel().getNumaEnabled().setMessage(constants.numaInfoMessage());
} else {
getModel().getNumaEnabled().setMessage(constants.numaDisabledInfoMessage());
getModel().getNumaNodeCount().setEntity(0);

}
getModel().getNumaEnabled().setEntity(enabled);
}
Expand Down