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

nil pointer dereference when switching contexts #2656

Closed
doy-materialize opened this issue Apr 15, 2024 · 0 comments · Fixed by #2659
Closed

nil pointer dereference when switching contexts #2656

doy-materialize opened this issue Apr 15, 2024 · 0 comments · Fixed by #2659

Comments

@doy-materialize
Copy link
Contributor




Describe the bug
when using :context to switch to certain contexts i have defined, k9s panics with a nil pointer dereference error

To Reproduce
i don't actually know why some contexts work fine and others fail. with the ones that fail, i can successfully use k9s --context to switch to those contexts at startup, so it appears to only be an issue when using :context.

Historical Documents
k9s.log:

�[90m1:53PM�[0m �[32mINF�[0m �[1m🐶 K9s starting up...�[0m
�[90m1:53PM�[0m �[31mERR�[0m �[1mFail to locate metrics-server�[0m �[36merror=�[0m�[31m�[1m"No metrics api group metrics.k8s.io found on cluster"�[0m�[0m
�[90m1:53PM�[0m �[32mINF�[0m �[1m✅ Kubernetes connectivity�[0m
�[90m1:53PM�[0m �[31mERR�[0m �[1mUsing "default" namespace�[0m
�[90m1:53PM�[0m �[31mERR�[0m �[1mBoom! runtime error: invalid memory address or nil pointer dereference�[0m
�[90m1:53PM�[0m �[31mERR�[0m �[1mgoroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x5e
github.com/derailed/k9s/cmd.run.func2()
	github.com/derailed/k9s/cmd/root.go:97 +0xb1
panic({0x64269c5c2260?, 0x64269e7c4380?})
	runtime/panic.go:770 +0x132
github.com/derailed/tview.(*Application).Run.func1()
	github.com/derailed/[email protected]/application.go:243 +0x45
panic({0x64269c5c2260?, 0x64269e7c4380?})
	runtime/panic.go:770 +0x132
github.com/derailed/k9s/internal/config/data.(*Namespace).merge(0xc00132a1e0, 0x0)
	github.com/derailed/k9s/internal/config/data/ns.go:49 +0x9c
github.com/derailed/k9s/internal/config/data.(*Context).merge(...)
	github.com/derailed/k9s/internal/config/data/context.go:59
github.com/derailed/k9s/internal/config/data.(*Config).Merge(0x0?, 0xc00005c540?)
	github.com/derailed/k9s/internal/config/data/config.go:34 +0x33
github.com/derailed/k9s/internal/config/data.(*Dir).Save(0xc000bb7350, {0xc00005c540, 0x67}, 0xc0004a87e0)
	github.com/derailed/k9s/internal/config/data/dir.go:66 +0x5b
github.com/derailed/k9s/internal/config.(*K9s).Save(0xc000d5c780, 0x1)
	github.com/derailed/k9s/internal/config/k9s.go:84 +0x149
github.com/derailed/k9s/internal/config.(*Config).Save(0xc000df31a0, 0x1)
	github.com/derailed/k9s/internal/config/config.go:239 +0x37
github.com/derailed/k9s/internal/view.(*App).switchContext(0xc000880d80, 0xc001679410, 0x1)
	github.com/derailed/k9s/internal/view/app.go:471 +0x4f0
github.com/derailed/k9s/internal/view.useContext(0xc000880d80, {0xc000e8e7a0, 0x1b})
	github.com/derailed/k9s/internal/view/context.go:130 +0x23f
github.com/derailed/k9s/internal/view.(*Context).useCtx(0xc00167d9f0, 0xc000880d80, {0xc001679580?, 0x64269ad91014?}, {{0x64269aea1496, 0x8}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
	github.com/derailed/k9s/internal/view/context.go:105 +0xe5
github.com/derailed/k9s/internal/view.(*Browser).enterCmd(0xc000f9d800, 0xc00049de00)
	github.com/derailed/k9s/internal/view/browser.go:374 +0x10c
github.com/derailed/k9s/internal/view.(*Table).keyboard(0xc00175ebc0, 0xc00049de00)
	github.com/derailed/k9s/internal/view/table.go:97 +0x129
github.com/derailed/k9s/internal/view.(*Browser).InputHandler.(*Table).InputHandler.(*Box).WrapInputHandler.func2(0x6426987770a5?, 0xc0019098b0)
	github.com/derailed/[email protected]/box.go:179 +0x37
github.com/derailed/k9s/internal/view.(*PageStack).InputHandler.(*Pages).InputHandler.func1(0xc00049de00, 0xc0019098b0)
	github.com/derailed/[email protected]/pages.go:332 +0xa2
github.com/derailed/k9s/internal/view.(*PageStack).InputHandler.(*Pages).InputHandler.(*Box).WrapInputHandler.func2(0xc0016797d0?, 0x6426987770a5?)
	github.com/derailed/[email protected]/box.go:182 +0x50
github.com/derailed/tview.(*Flex).InputHandler.func1(0xc00049de00, 0xc0019098b0)
	github.com/derailed/[email protected]/flex.go:261 +0xd7
github.com/derailed/tview.(*Flex).InputHandler.(*Box).WrapInputHandler.func2(0xc0013e7d70?, 0xc000500008?)
	github.com/derailed/[email protected]/box.go:182 +0x50
github.com/derailed/k9s/internal/ui.(*Pages).InputHandler.(*Pages).InputHandler.func1(0xc00049de00, 0xc0019098b0)
	github.com/derailed/[email protected]/pages.go:332 +0xa2
github.com/derailed/k9s/internal/ui.(*Pages).InputHandler.(*Pages).InputHandler.(*Box).WrapInputHandler.func2(0xc001679948?, 0xc0016798b0?)
	github.com/derailed/[email protected]/box.go:182 +0x50
github.com/derailed/tview.(*Application).Run(0xc0006f8460)
	github.com/derailed/[email protected]/application.go:334 +0x518
github.com/derailed/k9s/internal/view.(*App).Run(0xc000880d80)
	github.com/derailed/k9s/internal/view/app.go:536 +0x8f
github.com/derailed/k9s/cmd.run(0xc000be6800?, {0x64269ae973ec?, 0x4?, 0x64269ae97304?})
	github.com/derailed/k9s/cmd/root.go:115 +0x3a5
github.com/spf13/cobra.(*Command).execute(0x64269e80ccc0, {0xc000132000, 0x0, 0x0})
	github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x64269e80ccc0)
	github.com/spf13/[email protected]/command.go:1115 +0x3ff
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 +0x1a
main.main()
	./main.go:32 +0xf
�[0m

Expected behavior
it shouldn't crash

Versions (please complete the following information):

  • OS: arch linux
  • K9s: 0.32.4
  • K8s: 1.27.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant