Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: handle node pool requests to older regions #18021

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/18021.txt
Original file line number Diff line number Diff line change
@@ -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
```
17 changes: 17 additions & 0 deletions ui/app/adapters/node-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: pretty specific and therefore fragile in the future! If we have an option to look for a particular status code, I'd opt for that. Guessing not the case here, though.

Copy link
Member

@tgross tgross Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #16743 we can finally start doing that sort of thing. But almost none of the API uses it yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have noted this somewhere (either in code or the PR comment), but this line is to protect against old releases, so there's no chance to break in the future (unless we really want to 😬) since this message is baked in the binaries.

To better explain why this check is needed, imagine you use the 1.6.x UI code to access a cluster running Nomad 1.5.x. The 1.6.x UI code will make a request for GET /v1/node/pools, which the 1.5.x server interprets as a read for the node with ID pools, resulting in this error message.

We can change the logic for the next 1.5.x release (1.5.9 at the time of this writing), but we will still need to check for this specific error message to support any versions before that. I also used the exact error message to prevent false positives.

The other important part is that, in practice, this won't happen in a real cluster until we allow running a stand-alone UI. In a real federated cluster, accessing a region running Nomad 1.6.x from the UI of a Nomad 1.5.x region will result in the error handled in #18020 because the request is forwarded via RPCs.

);
if (isNodeRequest) {
return [];
}

// Rethrow to be handled downstream.
throw error;
});
}
}
2 changes: 1 addition & 1 deletion ui/app/templates/clients/client/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion ui/app/templates/components/client-node-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/job-page/parts/stats-box.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/job-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down