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

k9s panics on start if the main config file (config.yml) is owned by root #2569

Closed
abovestratosphere opened this issue Feb 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@abovestratosphere
Copy link




Describe the bug
If the k8s config.yml is owned by root, k9s will throw Boom!! runtime error: invalid memory address or nil pointer dereference. because this check doesn't check for os.IsPermission, so f will be nil.

Logs:

9:53PM ERR Boom! runtime error: invalid memory address or nil pointer dereference
9:53PM ERR goroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x64
github.com/derailed/k9s/cmd.run.func2()
	github.com/derailed/k9s/cmd/root.go:97 +0x9c
panic({0x1032f3ee0?, 0x105459370?})
	runtime/panic.go:914 +0x218
github.com/derailed/k9s/internal/config/data.(*Dir).Load(0x14000c2c1c8, {0x14000988a00?, 0x3c?}, 0x1400088d450)
	github.com/derailed/k9s/internal/config/data/dir.go:42 +0xe0
github.com/derailed/k9s/internal/config.(*K9s).ActivateContext(0x1400075c000, {0x14000988a00, 0x3c})
	github.com/derailed/k9s/internal/config/k9s.go:207 +0x68
github.com/derailed/k9s/internal/config.(*Config).Refine(0x14000e6e780, 0x14000e64120, 0x1400009c600, 0x140002df720?)
	github.com/derailed/k9s/internal/config/config.go:79 +0x168
github.com/derailed/k9s/cmd.loadConfiguration()
	github.com/derailed/k9s/cmd/root.go:141 +0x394
github.com/derailed/k9s/cmd.run(0x14000af4200?, {0x10247a874?, 0x4?, 0x10247a79c?})
	github.com/derailed/k9s/cmd/root.go:107 +0x37c
github.com/spf13/cobra.(*Command).execute(0x105489a60, {0x1400004c0b0, 0x0, 0x0})
	github.com/spf13/[email protected]/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x105489a60)
	github.com/spf13/[email protected]/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:1039
github.com/derailed/k9s/cmd.Execute()
	github.com/derailed/k9s/cmd/root.go:70 +0x24
main.main()
	github.com/derailed/k9s/main.go:32 +0x1c

To Reproduce
Steps to reproduce the behavior:

  1. chown your k8s config.yml to root
  2. run k9s

Expected behavior
I think in this case, a helpful error message would be desired, instead of a panic.
Can also suggest something like run k9s with sudo, or chown your config or something.

Versions (please complete the following information):

  • OS: OSX
  • K9s: v0.31.9
  • K8s:
    Client Version: v1.27.2
    Kustomize Version: v5.0.1
    Server Version: v1.28.5-eks-5e0fdde
@derailed derailed added the bug Something isn't working label Mar 2, 2024
derailed added a commit that referenced this issue Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants