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

frontend: add node shell #1603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

farodin91
Copy link
Contributor

@farodin91 farodin91 commented Dec 16, 2023

image

Follow up PR:

  • Windows Support
  • Improved Error handling

fixes #996

@farodin91 farodin91 changed the title Add node shell frontend: add node shell Dec 18, 2023
@farodin91 farodin91 force-pushed the add-node-shell branch 2 times, most recently from c35b741 to 7f240c1 Compare December 18, 2023 19:13
@farodin91 farodin91 marked this pull request as ready for review January 10, 2024 15:06
@farodin91
Copy link
Contributor Author

@joaquimrocha What do you think of this?

@joaquimrocha
Copy link
Collaborator

@farodin91 We had the intention of adding this but then things got stalled since apparently it's not possible to run it in all k8s environments. I will review it now though as I'd like to indeed have this.

frontend/src/components/common/Shell.tsx Outdated Show resolved Hide resolved
frontend/src/components/node/Details.tsx Outdated Show resolved Hide resolved
icon="mdi:console"
onClick={() => setShowShell(true)}
iconButtonProps={{
disabled: item?.status?.nodeInfo?.operatingSystem !== 'linux',
Copy link
Collaborator

Choose a reason for hiding this comment

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

We only disable buttons in the header actions if they are to be shown by default because the user can ever use them (e.g. no permissions -> hide button).
If the user has permissions but the OS is not Linux, I feel a bit divided because of the cases where the user never has a Linux node (so just like not having permissions to exec, we shouldn't show that action).

If it makes sense to have it disabled anyway, then we'd have to explain why it's disabled in the tooltip (we do this for the "show previous" button in the logs viewer dialog).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think of my change?

frontend/src/lib/k8s/node.ts Outdated Show resolved Hide resolved
@farodin91 farodin91 force-pushed the add-node-shell branch 3 times, most recently from c171dd8 to 7e87ed8 Compare January 14, 2024 17:49
Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

Pretty cool to have this feature! I left a few comments. Let me know if you have any questions or need to discuss it (we can also do it in the community slack).

frontend/src/components/App/Settings/SettingsCluster.tsx Outdated Show resolved Hide resolved
const invalidNamespaceMessage = t(
"translation|Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character."
);
const isValidNewAllowedNamespace = isValidNamespaceFormat(newAllowedNamespace);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this moved here?

frontend/src/components/App/Settings/SettingsCluster.tsx Outdated Show resolved Hide resolved
value={dropShellLinuxImage}
placeholder={DEFAULT_DROP_SHELL_LINUX_IMAGE}
helperText={t(
'translation|The default image is used for dropping a shell into a node (when not specified directly).'
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does "when not specified directly" refer to?

frontend/src/components/node/Details.tsx Outdated Show resolved Hide resolved
frontend/src/helpers/index.ts Outdated Show resolved Hide resolved
frontend/src/i18n/locales/de/glossary.json Outdated Show resolved Hide resolved
Comment on lines +138 to +161
const url = `/api/v1/namespaces/kube-system/pods/${podName}/exec?container=shell${commandStr}&stdin=${
stdin ? 1 : 0
}&stderr=${stderr ? 1 : 0}&stdout=${stdout ? 1 : 0}&tty=${tty ? 1 : 0}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The 1st time I tried your PR, it failed to show any terminal. I think it's because the image was not pulled and it took longer? After re-trying it did work. Maybe you can reproduce it by using an always pull policy in the pod during dev.

I wonder if we can somehow show a spinner and wait till the pod is available, for a better UX.

frontend/src/components/common/Terminal.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think making the Terminal dependent on a node or pod is not the right direction here. After all we are execing into a pod.
I wonder if instead of passing the node so it executes the shell command there, we could instead override the exec method for that pod instance, either directly in that instance, or by creating a new Pod class (NodeShellPod) with that new exec method, and we instantiate it from the json of the created Pod.

I understand the exec is not the only thing you're branching on. But e.g. things like hiding the container selector could be a new property like showContainerSelector?: boolean; not circling through the shells could be achieved by overriding the list of shells from a property too, and if this list has only 1 element, there's no point in circling (shellCommand?: string[] | string); the title can be a new title property.

I hope we don't end up with 10 more properties but perhaps just 3 or 4. This would make the terminal more flexible without special casing it for the node. These changes should be independent commits.

I know it's yet more work, but do you think this makes sense?

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 started to work on it.

I'm currently think of splitting up the terminal any logic such as attach or not or container selector and building a Terminal dialog for pods and nodes. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a Terminal dialog for pods and nodes is fine if that makes the code simpler, as long as they use the same underlying component. Since we are in any case execing into the same type of resource, it's just some options on how to connect and what to show that change, I think it's probably easier to just have those exposed in the Terminal and calling it differently depending on whether it's the Node shell or the Pod one.

@joaquimrocha
Copy link
Collaborator

BTW, forgot to mention that one difference I see in UX with the regular pod exec functionality is that the node one shows a very narrow dialog for a little bit until the terminal is actually rendered. The same doesn't happen for the pod exec as far as I could test.

@farodin91
Copy link
Contributor Author

I'm vacation at moment. I will come back in one half week.

Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

I commented on your last reply. I see you updated the branch but the logic still needs to address the review, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a Terminal dialog for pods and nodes is fine if that makes the code simpler, as long as they use the same underlying component. Since we are in any case execing into the same type of resource, it's just some options on how to connect and what to show that change, I think it's probably easier to just have those exposed in the Terminal and calling it differently depending on whether it's the Node shell or the Pod one.

@illume
Copy link
Collaborator

illume commented May 13, 2024

I went through and closed convos that were done. It should be a bit easier to read the PR now.

@illume illume requested a review from joaquimrocha May 13, 2024 10:57
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 3, 2024
@farodin91
Copy link
Contributor Author

@illume I have rebased my changes and now they pass.

@farodin91
Copy link
Contributor Author

I thought about moving it to plugins. As a Plugin it would be possible to ship only if wanted and develop further. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for execing into a node
3 participants