-
Notifications
You must be signed in to change notification settings - Fork 174
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
base: main
Are you sure you want to change the base?
frontend: add node shell #1603
Conversation
c35b741
to
7f240c1
Compare
7f240c1
to
dd556db
Compare
@joaquimrocha What do you think of this? |
@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. |
icon="mdi:console" | ||
onClick={() => setShowShell(true)} | ||
iconButtonProps={{ | ||
disabled: item?.status?.nodeInfo?.operatingSystem !== 'linux', |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
c171dd8
to
7e87ed8
Compare
There was a problem hiding this 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).
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); |
There was a problem hiding this comment.
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?
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).' |
There was a problem hiding this comment.
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?
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}`; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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. |
I'm vacation at moment. I will come back in one half week. |
7e87ed8
to
be70ef5
Compare
There was a problem hiding this 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?
There was a problem hiding this comment.
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.
I went through and closed convos that were done. It should be a bit easier to read the PR now. |
be70ef5
to
03ef10f
Compare
@illume I have rebased my changes and now they pass. |
Fixes headlamp-k8s#996 Signed-off-by: farodin91 <[email protected]>
03ef10f
to
d0eb6f3
Compare
I thought about moving it to plugins. As a Plugin it would be possible to ship only if wanted and develop further. Any thoughts? |
Follow up PR:
fixes #996