Skip to content

Commit

Permalink
ui: fix Topology node state filter (#17940) (#17998)
Browse files Browse the repository at this point in the history
"Ineligible" and "Draining" are not determined by the node status, but
are rather inferred from other fields.

Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
  • Loading branch information
hc-github-team-nomad-core and lgfa29 committed Jul 19, 2023
1 parent 0edfae9 commit 2cb8786
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/17940.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed a bug that prevented nodes from being filtered by the "Ineligible" and "Draining" state filters
```
7 changes: 6 additions & 1 deletion ui/app/controllers/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ export default class TopologyControllers extends Controller.extend(Searchable) {
selectionDatacenter,
selectionClass,
} = this;
const matchState =
selectionState.includes(node.status) ||
(selectionState.includes('ineligible') && !node.isEligible) ||
(selectionState.includes('draining') && node.isDraining);
return (
(selectionState.length ? selectionState.includes(node.status) : true) &&
(selectionState.length ? matchState : true) &&
(selectionVersion.length
? selectionVersion.includes(node.version)
: true) &&
Expand Down
52 changes: 50 additions & 2 deletions ui/tests/acceptance/topology-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,22 +317,70 @@ module('Acceptance | topology', function (hooks) {
server.createList('node', 2, {
nodeClass: 'foo-bar-baz',
});

// Make sure we have at least one node draining and one ineligible.
server.create('node', {
schedulingEligibility: 'ineligible',
});
server.create('node', 'draining');

server.createList('allocation', 5);

// Count draining and ineligible nodes.
const counts = {
ineligible: 0,
draining: 0,
};
server.db.nodes.forEach((n) => {
if (n.schedulingEligibility === 'ineligible') {
counts['ineligible'] += 1;
}
if (n.drain) {
counts['draining'] += 1;
}
});

await Topology.visit();
assert.dom('[data-test-topo-viz-node]').exists({ count: 12 });
assert.dom('[data-test-topo-viz-node]').exists({ count: 14 });

// Test search.
await typeIn('input.node-search', server.schema.nodes.first().name);
assert.dom('[data-test-topo-viz-node]').exists({ count: 1 });
await typeIn('input.node-search', server.schema.nodes.first().name);
assert.dom('[data-test-topo-viz-node]').doesNotExist();
await click('[title="Clear search"]');
assert.dom('[data-test-topo-viz-node]').exists({ count: 12 });
assert.dom('[data-test-topo-viz-node]').exists({ count: 14 });

// Test node class filter.
await Topology.facets.class.toggle();
await Topology.facets.class.options
.findOneBy('label', 'foo-bar-baz')
.toggle();
assert.dom('[data-test-topo-viz-node]').exists({ count: 2 });
await Topology.facets.class.options
.findOneBy('label', 'foo-bar-baz')
.toggle();

// Test ineligible state filter.
await Topology.facets.state.toggle();
await Topology.facets.state.options
.findOneBy('label', 'Ineligible')
.toggle();
assert
.dom('[data-test-topo-viz-node]')
.exists({ count: counts['ineligible'] });
await Topology.facets.state.options
.findOneBy('label', 'Ineligible')
.toggle();
await Topology.facets.state.toggle();

// Test draining state filter.
await Topology.facets.state.toggle();
await Topology.facets.state.options.findOneBy('label', 'Draining').toggle();
assert
.dom('[data-test-topo-viz-node]')
.exists({ count: counts['draining'] });
await Topology.facets.state.options.findOneBy('label', 'Draining').toggle();
await Topology.facets.state.toggle();
});
});

0 comments on commit 2cb8786

Please sign in to comment.