From 3cbcded1eb177f90ddc53618eed02fb65f76f490 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Wed, 12 Feb 2025 14:47:40 -0500 Subject: [PATCH] Very basic checkbox and mirage alloc placement depending on running node --- ui/app/components/topo-viz.js | 1 + ui/app/controllers/topology.js | 5 ++++- ui/app/routes/topology.js | 1 + ui/app/templates/topology.hbs | 11 ++++++++++- ui/mirage/factories/allocation.js | 4 +++- ui/mirage/scenarios/default.js | 6 ++++++ 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ui/app/components/topo-viz.js b/ui/app/components/topo-viz.js index b33a7d34cda..6560bec9fbc 100644 --- a/ui/app/components/topo-viz.js +++ b/ui/app/components/topo-viz.js @@ -93,6 +93,7 @@ export default class TopoViz extends Component { buildTopology() { const nodes = this.args.nodes; const allocations = this.args.allocations; + console.log('building topo', nodes, allocations); // Nodes may not have a resources property due to having an old Nomad agent version. const badNodes = []; diff --git a/ui/app/controllers/topology.js b/ui/app/controllers/topology.js index ef67674ec46..ea8af6c2c02 100644 --- a/ui/app/controllers/topology.js +++ b/ui/app/controllers/topology.js @@ -157,6 +157,8 @@ export default class TopologyControllers extends Controller.extend(Searchable) { @alias('userSettings.showTopoVizPollingNotice') showPollingNotice; + @tracked showEmptyNodes = true; + @tracked pre09Nodes = null; get filteredNodes() { @@ -191,7 +193,8 @@ export default class TopologyControllers extends Controller.extend(Searchable) { : true) && (node.name.includes(searchTerm) || node.datacenter.includes(searchTerm) || - node.nodeClass.includes(searchTerm)) + node.nodeClass.includes(searchTerm)) && + (this.showEmptyNodes || node.allocations.length > 0) ); }); } diff --git a/ui/app/routes/topology.js b/ui/app/routes/topology.js index 606872c4897..338f8f97940 100644 --- a/ui/app/routes/topology.js +++ b/ui/app/routes/topology.js @@ -16,6 +16,7 @@ export default class TopologyRoute extends Route.extend(WithForbiddenState) { @service system; model() { + console.log('re-firing model'); return RSVP.hash({ allocations: this.store.query('allocation', { resources: true, diff --git a/ui/app/templates/topology.hbs b/ui/app/templates/topology.hbs index de6c9e9acba..b3bab7d59f3 100644 --- a/ui/app/templates/topology.hbs +++ b/ui/app/templates/topology.hbs @@ -487,6 +487,14 @@
+ {{!-- HDS checkbox for selecting whether to show or hide empty nodes, default true --}} + Show empty nodes? {{this.showEmptyNodes}} + + Show Empty Nodes + +
+ {{log "Allocations from topology.hbs" this.model.allocations}} {{/if}} - \ No newline at end of file + diff --git a/ui/mirage/factories/allocation.js b/ui/mirage/factories/allocation.js index 548477d50a0..8e7d717ba4a 100644 --- a/ui/mirage/factories/allocation.js +++ b/ui/mirage/factories/allocation.js @@ -194,7 +194,9 @@ export default Factory.extend({ const namespace = allocation.namespace || job.namespace; const node = allocation.nodeId ? server.db.nodes.find(allocation.nodeId) - : pickOne(server.db.nodes); + : pickOne( + server.db.nodes.where({ status: 'ready' }) || pickOne(server.db.nodes) + ); const taskGroup = allocation.taskGroup ? server.db.taskGroups.findBy({ name: allocation.taskGroup }) : pickOne(server.db.taskGroups.where({ jobId: job.id })); diff --git a/ui/mirage/scenarios/default.js b/ui/mirage/scenarios/default.js index 87609668d80..60004923e38 100644 --- a/ui/mirage/scenarios/default.js +++ b/ui/mirage/scenarios/default.js @@ -105,6 +105,12 @@ function smallCluster(server) { }, 'withMeta' ); + // Create one more node that is unusable + server.create('node', { + name: 'unusable-node', + status: 'down', + meta: { unusable: true }, + }); server.createList('job', 10, { createRecommendations: true }); server.create('job', { withGroupServices: true,