Skip to content

Commit

Permalink
Very basic checkbox and mirage alloc placement depending on running node
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Feb 12, 2025
1 parent 716df52 commit 3cbcded
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions ui/app/components/topo-viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
5 changes: 4 additions & 1 deletion ui/app/controllers/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export default class TopologyControllers extends Controller.extend(Searchable) {

@alias('userSettings.showTopoVizPollingNotice') showPollingNotice;

@tracked showEmptyNodes = true;

@tracked pre09Nodes = null;

get filteredNodes() {
Expand Down Expand Up @@ -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)
);
});
}
Expand Down
1 change: 1 addition & 0 deletions ui/app/routes/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion ui/app/templates/topology.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@
</div>
<div class="toolbar-item is-right-aligned is-mobile-full-width">
<div class="button-bar">
{{!-- HDS checkbox for selecting whether to show or hide empty nodes, default true --}}
Show empty nodes? {{this.showEmptyNodes}}
<Hds::Form::Checkbox::Field checked={{this.showEmptyNodes}} name="show-empty-nodes"
{{on "change" (fn (mut this.showEmptyNodes) (not this.showEmptyNodes))}}
as |F|>
<F.Label>Show Empty Nodes</F.Label>
</Hds::Form::Checkbox::Field>

<MultiSelectDropdown
data-test-node-pool-facet
@label="Node Pool"
Expand Down Expand Up @@ -525,6 +533,7 @@
</div>
</div>
</div>
{{log "Allocations from topology.hbs" this.model.allocations}}
<TopoViz
@nodes={{this.filteredNodes}}
@allocations={{this.model.allocations}}
Expand All @@ -541,4 +550,4 @@
</div>
{{/if}}
</section>
</PageLayout>
</PageLayout>
4 changes: 3 additions & 1 deletion ui/mirage/factories/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down
6 changes: 6 additions & 0 deletions ui/mirage/scenarios/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3cbcded

Please sign in to comment.