Skip to content

panic on run without current context #2458

@markwellis

Description

@markwellis




Describe the bug
When I launch k9s it panics

panic: unable to activate context "": getcontext - invalid context specified: ""

goroutine 1 [running]:
github.com/derailed/k9s/cmd.Execute(...)
	/builddir/build/BUILD/k9s-0.31.2/cmd/root.go:60
main.main()
	/builddir/build/BUILD/k9s-0.31.2/main.go:32 +0x3c

This is because I have 7 kubernetes contexts defined, and no current context configured.

$ kubectl config view | grep "current"
current-context: ""

I always pass --context to kubectl. k9s used to open on the contexts page and I could select which one from there. Something has changed since version 0.29 which is the previous version I had installed that worked fine with this setup.

To Reproduce
Steps to reproduce the behavior:

  1. unset the current kubectl context, kubectl config unset current-context
  2. run k9s
  3. see error
  4. set kubectl current context, kubectl config use-context $context_name
  5. run k9s
  6. works

Expected behavior
If no current context is set, then open on the contexts page

Versions (please complete the following information):

  • OS: Linux, Fedora 39
  • K9s: v0.31.2
  • K8s: v1.27.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions