Skip to content

Commit 37e1551

Browse files
When the topo viz filters out nodes, report this to the user via warning alert
1 parent 4d5fef6 commit 37e1551

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

ui/app/controllers/topology.js

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Controller from '@ember/controller';
22
import { computed, action } from '@ember/object';
33
import { alias } from '@ember/object/computed';
44
import { inject as service } from '@ember/service';
5+
import { tracked } from '@glimmer/tracking';
56
import classic from 'ember-classic-decorator';
67
import { reduceToLargestUnit } from 'nomad-ui/helpers/format-bytes';
78

@@ -13,6 +14,8 @@ export default class TopologyControllers extends Controller {
1314

1415
@alias('userSettings.showTopoVizPollingNotice') showPollingNotice;
1516

17+
@tracked filteredNodes = null;
18+
1619
@computed('[email protected]')
1720
get datacenters() {
1821
return Array.from(new Set(this.model.nodes.mapBy('datacenter'))).compact();
@@ -117,4 +120,12 @@ export default class TopologyControllers extends Controller {
117120
setNode(node) {
118121
this.set('activeNode', node);
119122
}
123+
124+
@action
125+
handleTopoVizDataError(errors) {
126+
const filteredNodesError = errors.findBy('type', 'filtered-nodes');
127+
if (filteredNodesError) {
128+
this.filteredNodes = filteredNodesError.context;
129+
}
130+
}
120131
}

ui/app/templates/topology.hbs

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
{{#if this.isForbidden}}
55
<ForbiddenMessage />
66
{{else}}
7+
{{#if this.filteredNodes}}
8+
<div class="notification is-warning">
9+
<div data-test-filtered-nodes-warning class="columns">
10+
<div class="column">
11+
<h3 data-test-title class="title is-4">Some Clients Were Filtered</h3>
12+
<p data-test-message>{{this.filteredNodes.length}} {{if (eq this.filteredNodes.length 1) "client was" "clients were"}} filtered from the topology visualization. This is most likely due to the {{pluralize "client" this.filteredNodes.length}} running a version of Nomad &lt;0.9.0.</p>
13+
</div>
14+
<div class="column is-centered is-minimum">
15+
<button data-test-dismiss class="button is-warning" onclick={{action (mut this.filteredNodes) null}} type="button">Okay</button>
16+
</div>
17+
</div>
18+
</div>
19+
{{/if}}
720
<div class="columns">
821
<div class="column is-narrow is-400">
922
{{#if this.showPollingNotice}}
@@ -217,7 +230,8 @@
217230
@nodes={{this.model.nodes}}
218231
@allocations={{this.model.allocations}}
219232
@onAllocationSelect={{action this.setAllocation}}
220-
@onNodeSelect={{action this.setNode}} />
233+
@onNodeSelect={{action this.setNode}}
234+
@onDataError={{action this.handleTopoVizDataError}}/>
221235
</div>
222236
</div>
223237
{{/if}}

ui/tests/acceptance/topology-test.js

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module('Acceptance | topology', function(hooks) {
2929

3030
await Topology.visit();
3131
assert.equal(Topology.infoPanelTitle, 'Cluster Details');
32+
assert.notOk(Topology.filteredNodesWarning.isPresent);
3233
});
3334

3435
test('all allocations for all namespaces and all clients are queried on load', async function(assert) {
@@ -74,4 +75,15 @@ module('Acceptance | topology', function(hooks) {
7475
await Topology.viz.datacenters[0].nodes[0].selectNode();
7576
assert.equal(Topology.infoPanelTitle, 'Client Details');
7677
});
78+
79+
test('when one or more nodes lack the NodeResources property, a warning message is shown', async function(assert) {
80+
server.createList('node', 3);
81+
server.createList('allocation', 5);
82+
83+
server.schema.nodes.all().models[0].update({ nodeResources: null });
84+
85+
await Topology.visit();
86+
assert.ok(Topology.filteredNodesWarning.isPresent);
87+
assert.ok(Topology.filteredNodesWarning.message.startsWith('1'));
88+
});
7789
});

ui/tests/pages/topology.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { create, text, visitable } from 'ember-cli-page-object';
22

33
import TopoViz from 'nomad-ui/tests/pages/components/topo-viz';
4+
import notification from 'nomad-ui/tests/pages/components/notification';
45

56
export default create({
67
visit: visitable('/topology'),
78

89
infoPanelTitle: text('[data-test-info-panel-title]'),
10+
filteredNodesWarning: notification('[data-test-filtered-nodes-warning]'),
911

1012
viz: TopoViz('[data-test-topo-viz]'),
1113
});

0 commit comments

Comments
 (0)