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] Actions implementation in the web UI #18793

Merged
merged 23 commits into from
Nov 7, 2023

Conversation

philrenaud
Copy link
Contributor

@philrenaud philrenaud commented Oct 18, 2023

The Web UI implementation of Nomad Actions

This adds Actions dropdowns to job pages and task rows in tables and jobs where applicable, then runs a websocket query to execute them against a new job/:id/action endpoint.

image
image

PR review note: there is quite a bit of noise here from a groupTaskCount to groupAllocCount for in many mirage mocked jobs. This name better reflects what is actually being done in the job factory, as I've added a lever to help separate out task and alloc counts when creating one (this became relevant in order to mock a job with multiple groups with differing numbers of tasks and allocs)

Another note on design: the "streaming messages in a code block in a notification" is probably not the end state of the design for this feature, but since it is still in flux, I've opted to move this PR forward and address design changes in the near future.

@philrenaud philrenaud self-assigned this Oct 18, 2023
@github-actions
Copy link

github-actions bot commented Oct 18, 2023

Ember Test Audit comparison

main 036d61e change
passes 1534 1538 +4
failures 1 0 -1
flaky 0 0 0
duration 000ms 14m 01s 289ms +14m 01s 289ms

@philrenaud philrenaud force-pushed the 18735-socket-endpoint branch from fb1f31a to 0a308a1 Compare October 18, 2023 14:23
@philrenaud philrenaud force-pushed the 18782-implementation-on-job-index branch from ef434de to b89d27a Compare October 18, 2023 14:35
@philrenaud philrenaud force-pushed the 18782-implementation-on-job-index branch from 477cfb4 to 14bec47 Compare October 20, 2023 00:43
@philrenaud philrenaud changed the title [ui] Actions implementation on job index [ui] Actions implementation in the web UI Oct 20, 2023
Base automatically changed from 18735-socket-endpoint to 18627-task-actions October 20, 2023 13:17
@philrenaud philrenaud force-pushed the 18782-implementation-on-job-index branch 2 times, most recently from b14f50e to b23a7f2 Compare October 20, 2023 13:36
@philrenaud philrenaud mentioned this pull request Oct 20, 2023
Base automatically changed from 18627-task-actions to main October 20, 2023 17:05
Copy link
Contributor

@DingoEatingFuzz DingoEatingFuzz left a comment

Choose a reason for hiding this comment

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

Super awesome work!

I think the headline for me (granted I haven't been in this code in a minute) is that there is a lot of exposure to websocket and xterm details in the action adapter.

There's a good chance that code never has to be looked at again, so I don't want to go so far as to say it should be refactored, but since we already have some of those utils for full-blown exec, maybe there is an opportunity to organize some of the common code.

Comment on lines 174 to 191
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const region = this.system.activeRegion;
const applicationAdapter = getOwner(this).lookup('adapter:application');
const prefix = `${
applicationAdapter.host || window.location.host
}/${applicationAdapter.urlPrefix()}`;

const wsUrl =
`${protocol}//${prefix}/job/${encodeURIComponent(job.get('id'))}/action` +
`?namespace=${job.get('namespace.id')}&action=${
action.name
}&allocID=${allocID}&task=${action.task.name}&group=${
action.task.taskGroup.name
}&tty=true&ws_handshake=true` +
(region ? `&region=${region}` : '');

// const socket = new WebSocket(wsUrl);
let socket;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to eventually try to use the sockets service here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ended up starting/stopping on this a couple times today; I think it's a good idea and will be marking it a TODO but I'm worried about drift from the exec implementation enough that I want to give it more consideration.

Comment on lines +249 to +251
JSON.stringify({
tty_size: { width: 250, height: 100 }, // Magic numbers, but they pass the eye test.
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is what we use the xterm-addon-fit for over in ExecTerminal.

ui/app/adapters/job.js Show resolved Hide resolved
ui/app/styles/core/notifications.scss Outdated Show resolved Hide resolved
ui/mirage/factories/task-group.js Show resolved Hide resolved
ui/tests/acceptance/actions-test.js Outdated Show resolved Hide resolved
}

if (job.groupAllocCount) {
groupProps.count = job.groupAllocCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose it was only a matter of time before this needed to be disambiguated.

@philrenaud philrenaud force-pushed the 18782-implementation-on-job-index branch from e828a3c to 036d61e Compare November 7, 2023 19:17
@philrenaud philrenaud merged commit 783572d into main Nov 7, 2023
@philrenaud philrenaud deleted the 18782-implementation-on-job-index branch November 7, 2023 20:29
Copy link

github-actions bot commented Feb 5, 2025

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implementation on Job Index
3 participants