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 service and flyout #19084

Merged
merged 27 commits into from
Nov 27, 2023
Merged

[ui] Actions service and flyout #19084

merged 27 commits into from
Nov 27, 2023

Conversation

philrenaud
Copy link
Contributor

@philrenaud philrenaud commented Nov 14, 2023

A re-think to how we've handled Nomad Actions in the UI. Specifically, this means to address:

  • Session-permanence of Actions. Formerly, the output of an Action existed in the context of a small "toast" notification in the bottom-right of the UI. Many of these could stack, making them cumbersome, and when closed (say, to save space on one's screen), the socket was closed as a result. Now, we have a dedicated flyout for holding a queue of actions, which can be closed without affecting the running action.
  • A global queue of actions. Actions previously existed within the context of a job and handling of their sockets and messages was done in the ephemeral adapter layer. In this PR, we establish the Actions Service, which can be injected throughout different pages in the app (to indicate how many background actions are running from the application homepage, for example)
  • Multi-alloc actions / peer handling. A feature of Nomad actions is that they can be run on individual allocations, or repeated efficiently across many allocations. The updated UI establishes "peer" allocations where an action is running, to greatly consolidate the footprint of a running action.

image
image
image

Resolves #19066

@philrenaud philrenaud self-assigned this Nov 14, 2023
Copy link

github-actions bot commented Nov 14, 2023

Ember Test Audit comparison

main 532f7ae change
passes 1538 1539 +1
failures 0 0 0
flaky 0 0 0
duration 10m 42s 460ms 10m 45s 538ms +03s 078ms

@philrenaud philrenaud force-pushed the 19066-actions-service-sidebar branch from c8935bd to ac1dd80 Compare November 16, 2023 14:53
@philrenaud philrenaud force-pushed the 19066-actions-service-sidebar branch from 7b22c91 to 42069a8 Compare November 17, 2023 14:41
@philrenaud philrenaud force-pushed the 19018-ui-actions-implementation-in-task-fly-out branch 2 times, most recently from 3c9c975 to eb68dab Compare November 21, 2023 14:47
* @param {string} allocID
* @returns {string}
*/
getActionSocketUrl(job, action, allocID) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file previously did much more than an Ember adapter ought to; it has since been moved to a dedicated Action service.

Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A componentized dropdown/select box, which we use on the Job page, the Task page, and within the Actions flyout (within the context of a job or a task)

Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A representation of a running action instance, or group of peered instances.

Here's 2 action-cards:
image

@philrenaud philrenaud force-pushed the 19066-actions-service-sidebar branch from be27f8e to cf26beb Compare November 22, 2023 06:20
@philrenaud philrenaud marked this pull request as ready for review November 22, 2023 06:20
@philrenaud philrenaud changed the title [ui] Refactor running Actions from Notifications to Sidebar [ui] Actions service and flyout Nov 22, 2023
@philrenaud philrenaud linked an issue Nov 22, 2023 that may be closed by this pull request
Copy link
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

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

LGTM! Great work, Phil!

I found the code surprisingly straightforward to follow (coming from a non-JS background) and very well-structured and clearly written.

I did a lot of smoke-testing and the feature behaves as expected, with some corner cases that I described in the comments.

*
* @param {import('../models/action-instance').default} actionInstance - The action instance model.
*/
handleSocketClose(actionInstance) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's something 🐟-y going on here. Whenever I stop actions, I get websocket errors from Nomad API.

    2023-11-23T15:17:59.002+0100 [ERROR] http: request failed: method=GET path="/v1/job/actions-demo/action?namespace=default&action=echo%20time&allocID=d2604ab1-97d2-2e0a-ee02-448aad287525&task=task&group=group&tty=true&ws_handshake=true" error="websocket: close 1005 (no status)" code=500

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is fixed by #19172 (thank you, @pkazmierczak!)

import { base64DecodeString } from '../utils/encode';
import config from 'nomad-ui/config/environment';

export default class NomadActionsService extends Service {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very well structured and easy to read code, I like it.

I found an issue with permissions that I'm a bit confused with. If I give myself a read policy with no write permissions, the behavior is as expected: no actions-related widgets or buttons appear anywhere in the UI. So far so good. But if I give myself a minimal ACL that should allow me to use actions:

namespace "default" {
  policy       = "read"
  capabilities = ["alloc-exec", "alloc-lifecycle"]
}

I then do get actions-related buttons and widgets, but whenever I try to run an action, I get a 500, and no output.

Logs say it's a permissions issue:

    2023-11-23T15:48:38.229+0100 [ERROR] http: request failed: method=GET path="/v1/job/actions-demo/action?namespace=default&action=weather&allocID=5a2ba29f-ae21-cab1-df29-388a8bd081b7&task=task&group=group&tty=true&ws_handshake=true" error="Permission denied" code=500

But the code is wrong then, shouldn't be a 500. Also the UI doesn't give useful feedback on this:

Screenshot 2023-11-23 at 15 51 18

Wouldn't it be better if it said that it's a permissions issue?

Or am I perhaps setting the ACL wrong somehow?

@@ -38,7 +38,7 @@ Usage: nomad alloc exec [options] <allocation> <command>
When ACLs are enabled, this command requires a token with the 'alloc-exec',
'read-job', and 'list-jobs' capabilities for the allocation's namespace. If
the task driver does not have file system isolation (as with 'raw_exec'),
this command requires the 'alloc-node-exec', 'read-job', and 'list-jobs'
this command requires the 'alloc-node-exec', 'alloc-exec', 'read-job', and 'list-jobs'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: in testing this out, noticed that raw_exec jobs required both alloc-exec AND alloc-node-exec capabilities. Updating the docs to reflect.

@philrenaud
Copy link
Contributor Author

Hi @pkazmierczak , thanks for the review — opened up an issue re: error frames/response headers not surfacing for websockets @ #19164

IMO we should handle that separate of this PR, but it should still be handled.

@pkazmierczak
Copy link
Contributor

IMO we should handle that separate of this PR

agreed.

Copy link

github-actions bot commented Feb 2, 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 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Actions service sidebar
2 participants