Closed Elyviere closed 3 weeks ago
Thank you for the excellent issue, it really helps! Unfortunately I'm a bit stumped here. Since you can't list all namespaces available, you would need to know them beforehand.
Atm, I can only come up with workarounds.
One of them is to specify a namespace in the config (the default is All), the second one is for me to add a Kubens command so you can change namespace using :Kubens
There are probably more places this might affect since I haven't thought about that at all and would love it if you could help me find those, it's hard to replicate this behaviour for me currently.
Do you have any other suggestions?
The "optimal" way in my opinion would be something like this:
<C-n>
Further improvements to this could then be:
This way, the end result for the user is barely any different than a user with full access. You always change namespaces with <C-n>
and the UI is essentially the same.
I will add that in my use-case I have access to several namespaces, I simply cannot list them. So, I think it's important to keep the ability to switch between namespaces on the fly, rather than defining a single namespace in config.
I agree, this sounds great.
kubectl.nvim remembers previously input namespaces and shows them as suggestions in the namespace window
I will probably wait and evaluate if this is needed but the rest sounds great.
Will start with this soon so hopefully we have this setup during the weekend.
Did something very close to your suggestion now, I can see further improvement in making it closer to how the filter (c-f) works with a combined input and suggestions but this should take care of the immediate issue.
Like your suggested workflow
Upon getting a "nul" in return, it shows a description like "Access to namespaces denied, please input your desired namespace:"
Implemented!
The user gets a free-text input field to type their desired namespace
Implemented!
Upon pressing enter, kubectl tries to change namespace to namespace input by the user
Implemented
Config allows defining a list of default namespaces that will always be available to choose in the namespace window
Implemented, although the input field will disappear when setting the namespace_fallback config.
I will add that in my use-case I have access to several namespaces, I simply cannot list them. So, I think it's important to keep the ability to switch between namespaces on the fly, rather than defining a single namespace in config.
I understand and agree, although, I would suggest setting a different default than "All" for namespacevalue in combination to the other settings.
Please test it out and see if it works as expected!
Closing since I believe this is working! Let me know otherwise!
Sorry I completely forgot about trying this. I updated and am now getting the following error:
¯¬ç Error 11:38:43 notify.error lazy.nvim Failed to run `config` for kubectl.nvim
...ocal/share/nvim/lazy/kubectl.nvim/lua/kubectl/config.lua:49: attempt to index local 'options' (a nil value)
# stacktrace:
- /kubectl.nvim/lua/kubectl/config.lua:49 _in_ **setup**
- /kubectl.nvim/lua/kubectl/init.lua:53 _in_ **setup**
- .config/nvim/lua/plugins/kubectl.lua:5 _in_ **config**
- .config/nvim/lua/config/lazy.lua:9
- dotfiles/.config/nvim/init.lua:2
I'm still able to open kubectl.nvim with my keymap vim.keymap.set("n", "<leader>k", '<cmd>lua require("kubectl").open()<cr>', { noremap = true, silent = true })
, but pressing C-n
just moves my cursor to the next line (similar to normal-mode 'j').
Looking in nvim/lua/plugins/kubectl.lua I'm getting the following warning (I split the .setup()
to a separate line to show where the warning was):
I took another look at the readme for kubectl.nvim and it looks like I've copied everything 1-1, so not sure what's going on there.
Could you try again? It seems I didn't allow no config params 😅
Tried again, config error fixed but the namespace fix isn't working.
Pressing <C-n>
gives the desired result, but after inputting a namespace and pressing enter the namespace window quickly flashes and reappears with the following text:
Removing gr
and replacing with my desired namespace and pressing enter again gives this error (and moves my cursor to the next line in the pop-up window, without editing the contents):
11:50:49 msg_show RPC[Error] code_name = InternalError, message = "Request getCompletions failed with message: tunneling socket could not be established, cause=socket hang up"
I will add that after quitting that window, my deployments in the namespace showed up correctly. So it seems like the namespace change was correctly applied! Just the extra pop-up window that needs to be fixed.
I think I found the issue, could you try again?
PS. thanks for updating this 🙏, some issues like this one seems to be dependant on the computer
Seems there is at least one related error to the original issue. When entering a deployment (i.e. pods are visable in the UI) and pressing gu
(It says <gu> usage
in the top, but in the <g?>
help menu it says it's <gu> Show Resources Used
, not sure which it is) an empty "k8s_top - Top" window pops up and I get the following error:
¯¬ç Error 11:56:51 notify.error Error from server (Forbidden): pods.metrics.k8s.io is forbidden: User "sso:elyviere@<redacted>.com" cannot list resource "pods" in API group "metrics.k8s.io" at the cluster scope
I will attempt to find any other commands that give similar errors.
Tried again, config error fixed but the namespace fix isn't working.
Pressing
<C-n>
gives the desired result, but after inputting a namespace and pressing enter the namespace window quickly flashes and reappears with the following text:Removing
gr
and replacing with my desired namespace and pressing enter again gives this error (and moves my cursor to the next line in the pop-up window, without editing the contents):11:50:49 msg_show RPC[Error] code_name = InternalError, message = "Request getCompletions failed with message: tunneling socket could not be established, cause=socket hang up"
Wow you work fast. Still the same error in commit ebd6dcb I'm afraid.
The top usage should be fixed in latest (forgot to consider namespace in that one), don't think there are any more hardcoded "-A" anywhere now (hopefully) But that namespace thing is weird...
Can confirm top thing is fixed. Can I help you debug the gr
somehow? Any logs you want me to provide? We can make a branch to debug it so we don't clutter main with logs.
I'd love that!
there is a branch now called fix/make_ns_popup_great_again
I added a print where I think the error is but also a potential fix
It has no idea.
13:15:04 msg_show this should be true otherwise it's not understanding what view we are on false
Hmm I was almost sure the async call was the problem, how are we testing this?
1: Open neovim
2: Toggle plugin
3: Press c-n
4: Type namespace
5 Press
Or are you doing it differently?
That is the exact way I'm doing it.
Breakthrough: When opening an actual file it works, but when opening nvim without a file I get the error. So in the first of your 5 steps above the difference would be
nvim anything
→ works
or just
nvim
→ breaks
So to be clear, I'm running LazyVim. So when I open nvim with just nvim
I'm greeted with this page:
When opening with nvim anything
I open an actual file, i.e. no LazyVim start page. I assume that start page is causing the issue here.
That's really interesting, will setup lazyvim and see if I get the same
Installed dashboard and indeed did get that behaviour!
Suddenly I'm unable to open kubectl.nvim any more. Tried returning to the main branch and I'm still unable to open it. Let me know if I should report it as a separate bug. This is the error I'm getting when I try to open the plugin with <leader>k
, and I'm left with an empty window:
¯¬ç Error 15:51:37 msg_show.lua_error Error executing vim.schedule lua callback: ...y/kubectl.nvim/lua/kubectl/views/services/definition.lua:40: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
...y/kubectl.nvim/lua/kubectl/views/services/definition.lua:40: in function 'processFunc'
...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:145: in function 'process'
...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:299: in function <...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:297>
¯¬ç Error 15:51:37 msg_show.lua_error Error executing vim.schedule lua callback: ...y/kubectl.nvim/lua/kubectl/views/services/definition.lua:40: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
...y/kubectl.nvim/lua/kubectl/views/services/definition.lua:40: in function 'processFunc'
...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:145: in function 'process'
...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:299: in function <...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:297>
I've attached a file with the inspection info of the plugin, since I expect it'll be something locally that's become messed up somehow. kubectl-nvim_inspection.txt
Yeah that's an issue that I've fixed in #171 but haven't merged it yet. I cherry picked the pick for services so it should work now, the other views probably have similar error for you but I'll try to merge it soon. I've merged it to our debug branch as well so should work in both main and branch now.
For the main issue, it's super confusing tbh on why it happens, tried adjusting to solve it but seems I have to rewrite it instead, will try later this evening with that.
Glad to hear you've already fixed that. I mean the remaining part of this issue is so small now, and only when opening while dashboard is open. It can definitely be delayed or honestly even left like this and just add it as a known issue. Nobody except me will ever run into it anyway lol.
Yeah that would be the most sane thing to do....however....I rewrote the namespace selection anyways 🤓
The first time I tried fixing this I kind of did a hack to make it work and figured I'd do it properly later. The namespace selection is a lot better now I believe, especially for those that have access to namespaces. There is still the autosuggestions missing but I'll drop it for now. I would love it if you could verify before I merge our branch 🙏
Very nicely done! Can confirm it all appears to be working now :)
Oh but I'm afraid I think I found a related error.
enter
on a pod)Expected result: The pop-up window closes
Actual result: The pop-up windows is cleared of content but does not close
After closing the pop-up window with :q any subsequent opening and closing of the pop-up window with q work as expected.
Yeah just verified, it seems to be the same issue with the dashboard again but for other buffer types. At least this fix is working, will look into what's causing those other buffers
for me the latest commit shows this:
No namespaces, no completions.
for me the latest commit shows this:
No namespaces, no completions.
now it's working. weird. maybe it just took time to load?
What's the right way to choose one? there's no completion so I must write the full name
hmmm maybe, was super confused on why it would look like that. The completion isn't done yet so if you go into normal mode you can use normal selection as we do when selecting pods for example.
Added a issue to keep track of the completion task: #188
I added a feature request for the namespace config: https://github.com/Ramilito/kubectl.nvim/issues/189
Let me know if I can help out with it. I don't know lua but how hard can it be.
Oh but I'm afraid I think I found a related error.
- Open Nvim dashboard
- Open kubectl.nvim
- Open a pop-up window (e.g. press
enter
on a pod)- Press q
Expected result: The pop-up window closes
Actual result: The pop-up windows is cleared of content but does not close
After closing the pop-up window with :q any subsequent opening and closing of the pop-up window with q work as expected.
I created a new issue for the above so we can close this issue!
Describe the bug I'm unable to change namespaces. When pressing
<C-n>
, nothing happens for about 1 minute, then I get the below error:To Reproduce
<leader>k
<C-n>
Expected behavior I assume some sort of pop-up with available namespaces to select?
Screenshots
Environment (please complete the following information):
Additional context I assume the error may be caused by my user not having full access to the cluster. I only have access to a few namespaces, and so any commands using
--all-namespaces
will return an error. Perhaps this addon is attempting to find all available namespaces and getting an error instead?For context, running
kubectl get namespaces
in terminal gives the following error:Error from server (Forbidden): namespaces is forbidden: User "b76729a2-1a1e-4625-93a4-7828836dc696" cannot list resource "namespaces" in API group "" at the cluster scope: access denied