k9s: Namespaces list is empty


Describe the bug

After some version of k9s list of namespaces stopped working. When switching to the view using :ns main part of the screen is totally empty, even the header is missing. When I try searching using / on the screen, K9S crashes with the following logs:

zerolog: could not write event: write /tmp/k9s-morigs.log: file already closed
zerolog: could not write event: write /tmp/k9s-morigs.log: file already closed
 ____  __.________
|    |/ _/   __   \______
|      < \____    /  ___/
|    |  \   /    /\___ \
|____|__ \ /____//____  >
        \/            \/

Boom!! runtime error: index out of range [-1].

To Reproduce Steps to reproduce the behavior:

  1. Type :ns

Expected behavior List of namespaces is shown

Screenshots

image

Versions (please complete the following information):

  • OS: WSL2 on Windows 10 (10.0.19043.1348).
  • K9s: v0.25.8
  • K8s: 1.21

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

This version (v0.25.10) breaks it for me. I do not have access to list namespaces or nodes so I learned the blind way :ns xxx :po but this version seams to fail to do the namespace change so it keeps being black after :po

Downgraded to v0.25.8 and it worked again.

Love the tool, keep up the good work.

k9s-stefan.log

1. If it's possible, it would be awesome to log all api-server requests and responses on debug level

AFAICT this isn’t currently possible via flags. If you build k9s locally, the hack I do to turn on client-go logging and get per request/response logging is:

diff --git a/main.go b/main.go
index dd4d99ad..2d10dab0 100644
--- a/main.go
+++ b/main.go
@@ -20,7 +20,7 @@ func init() {
        if err := flag.Set("stderrthreshold", "fatal"); err != nil {
                panic(err)
        }
-       if err := flag.Set("v", "0"); err != nil {
+       if err := flag.Set("v", "99"); err != nil {
                panic(err)
        }
 }

This should work like passing -v=99 to kubectl. Of course, you can use lower verbosity levels depending on what you’re troubleshooting. The output ends up in a debug log in a temp directory (previously it was part of k9s own log, but when I build off master it’s now in a separate file in the same directory).

@morigs You are awesome Igor! Thank you for this great analysis! I think you’ve highlighted some good issues and bugs in k9s. I think the access review is indeed an issue, along with the crash you’d mentioned above. I’ll push a patch up and let’s see if we can zero in a bit more on this deal. I’ll also add a trace level for debugging access issue on your clusters it won’t log everything (for now!) but will help us zero in if that’s still a deal after this next drop ie k9s -l trace