ui: handle node pool requests to older regions (#18021)

When accessing a region running a version of Nomad without node pools an
error was thrown because the request is handled by the nodes endpoint
which fails because it assumes `pools` is the node ID.
This commit is contained in:
Luiz Aoqui
2023-07-21 09:16:49 -04:00
committed by GitHub
parent 5d3639f304
commit 2b3dd86dc5
6 changed files with 26 additions and 4 deletions

3
.changelog/18021.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed a bug that could cause an error when accessing a region running versions of Nomad prior to 1.6.0
```

View File

@@ -14,4 +14,21 @@ export default class NodePoolAdapter extends ApplicationAdapter {
resource = pluralize(resource);
return `/v1/${relationshipResource}/${resource}`;
}
findAll() {
return super.findAll(...arguments).catch((error) => {
// Handle the case where the node pool request is sent to a region that
// doesn't have node pools and the request is handled by the nodes
// endpoint.
const isNodeRequest = error.message.includes(
'node lookup failed: index error: UUID must be 36 characters'
);
if (isNodeRequest) {
return [];
}
// Rethrow to be handled downstream.
throw error;
});
}
}

View File

@@ -247,7 +247,7 @@
<span class="term">
Node Pool
</span>
{{this.model.nodePool}}
{{#if this.model.nodePool}}{{this.model.nodePool}}{{else}}-{{/if}}
</span>
{{#if this.model.nodeClass}}
<span class="pair" data-test-node-class>

View File

@@ -18,7 +18,9 @@
</span>
</td>
<td data-test-client-address class="is-200px is-truncatable">{{this.node.httpAddr}}</td>
<td data-test-client-node-pool title="{{this.node.nodePool}}">{{this.node.nodePool}}</td>
<td data-test-client-node-pool title="{{this.node.nodePool}}">
{{#if this.node.nodePool}}{{this.node.nodePool}}{{else}}-{{/if}}
</td>
<td data-test-client-datacenter>{{this.node.datacenter}}</td>
<td data-test-client-version>{{this.node.version}}</td>
<td data-test-client-volumes>{{if this.node.hostVolumes.length this.node.hostVolumes.length}}</td>

View File

@@ -33,7 +33,7 @@
{{/if}}
<span class="pair" data-test-job-stat="node-pool">
<span class="term">Node Pool</span>
{{@job.nodePool}}
{{#if @job.nodePool}}{{@job.nodePool}}{{else}}-{{/if}}
</span>
{{yield to="after-namespace"}}
</div>

View File

@@ -47,7 +47,7 @@
{{this.job.displayType.type}}
</td>
<td data-test-job-node-pool>
{{this.job.nodePool}}
{{#if this.job.nodePool}}{{this.job.nodePool}}{{else}}-{{/if}}
</td>
<td data-test-job-priority>
{{this.job.priority}}