From 37e1551dcbe16338178c8152a7b7c9f14b32732c Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Tue, 5 Jan 2021 17:11:00 -0800 Subject: [PATCH] When the topo viz filters out nodes, report this to the user via warning alert --- ui/app/controllers/topology.js | 11 +++++++++++ ui/app/templates/topology.hbs | 16 +++++++++++++++- ui/tests/acceptance/topology-test.js | 12 ++++++++++++ ui/tests/pages/topology.js | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ui/app/controllers/topology.js b/ui/app/controllers/topology.js index 9b4d98fdf35..9bb0bec43e8 100644 --- a/ui/app/controllers/topology.js +++ b/ui/app/controllers/topology.js @@ -2,6 +2,7 @@ import Controller from '@ember/controller'; import { computed, action } from '@ember/object'; import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; +import { tracked } from '@glimmer/tracking'; import classic from 'ember-classic-decorator'; import { reduceToLargestUnit } from 'nomad-ui/helpers/format-bytes'; @@ -13,6 +14,8 @@ export default class TopologyControllers extends Controller { @alias('userSettings.showTopoVizPollingNotice') showPollingNotice; + @tracked filteredNodes = null; + @computed('model.nodes.@each.datacenter') get datacenters() { return Array.from(new Set(this.model.nodes.mapBy('datacenter'))).compact(); @@ -117,4 +120,12 @@ export default class TopologyControllers extends Controller { setNode(node) { this.set('activeNode', node); } + + @action + handleTopoVizDataError(errors) { + const filteredNodesError = errors.findBy('type', 'filtered-nodes'); + if (filteredNodesError) { + this.filteredNodes = filteredNodesError.context; + } + } } diff --git a/ui/app/templates/topology.hbs b/ui/app/templates/topology.hbs index e88731d8d52..c41b1de9c6b 100644 --- a/ui/app/templates/topology.hbs +++ b/ui/app/templates/topology.hbs @@ -4,6 +4,19 @@ {{#if this.isForbidden}} {{else}} + {{#if this.filteredNodes}} +
+
+
+

Some Clients Were Filtered

+

{{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 <0.9.0.

+
+
+ +
+
+
+ {{/if}}
{{#if this.showPollingNotice}} @@ -217,7 +230,8 @@ @nodes={{this.model.nodes}} @allocations={{this.model.allocations}} @onAllocationSelect={{action this.setAllocation}} - @onNodeSelect={{action this.setNode}} /> + @onNodeSelect={{action this.setNode}} + @onDataError={{action this.handleTopoVizDataError}}/>
{{/if}} diff --git a/ui/tests/acceptance/topology-test.js b/ui/tests/acceptance/topology-test.js index e641f1dbf32..70e510fb889 100644 --- a/ui/tests/acceptance/topology-test.js +++ b/ui/tests/acceptance/topology-test.js @@ -29,6 +29,7 @@ module('Acceptance | topology', function(hooks) { await Topology.visit(); assert.equal(Topology.infoPanelTitle, 'Cluster Details'); + assert.notOk(Topology.filteredNodesWarning.isPresent); }); 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) { await Topology.viz.datacenters[0].nodes[0].selectNode(); assert.equal(Topology.infoPanelTitle, 'Client Details'); }); + + test('when one or more nodes lack the NodeResources property, a warning message is shown', async function(assert) { + server.createList('node', 3); + server.createList('allocation', 5); + + server.schema.nodes.all().models[0].update({ nodeResources: null }); + + await Topology.visit(); + assert.ok(Topology.filteredNodesWarning.isPresent); + assert.ok(Topology.filteredNodesWarning.message.startsWith('1')); + }); }); diff --git a/ui/tests/pages/topology.js b/ui/tests/pages/topology.js index b9f2c63a6a6..63e38de2203 100644 --- a/ui/tests/pages/topology.js +++ b/ui/tests/pages/topology.js @@ -1,11 +1,13 @@ import { create, text, visitable } from 'ember-cli-page-object'; import TopoViz from 'nomad-ui/tests/pages/components/topo-viz'; +import notification from 'nomad-ui/tests/pages/components/notification'; export default create({ visit: visitable('/topology'), infoPanelTitle: text('[data-test-info-panel-title]'), + filteredNodesWarning: notification('[data-test-filtered-nodes-warning]'), viz: TopoViz('[data-test-topo-viz]'), });