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

Boom!! runtime error: invalid memory address or nil pointer dereference - v0.30.8 #2428

Closed
Loth4r opened this issue Jan 4, 2024 · 15 comments
Labels
bug Something isn't working InProgress Marks an issue has being worked on

Comments

@Loth4r
Copy link

Loth4r commented Jan 4, 2024




Describe the bug
k9s is crashing for me after update from 0.29.1 to v0.30.8 when switching through namespaces with following message: Boom!! runtime error: invalid memory address or nil pointer dereference

To Reproduce
Steps to reproduce the behavior:

  1. Launch k9s and type :namespaces to see namespaces view
  2. Go to any namespace hit enter -> error occurs -> Boom!! runtime error: invalid memory address or nil pointer dereference
  3. Launch k9s again and type :namespaces to see namespaces view
  4. Select same namespace as in point 2 -> view is working
  5. Get back to namespaces view again and select any other namespace -> Boom!! runtime error: invalid memory address or nil pointer dereference

Expected behavior
Browsing namespace works on the first try.

Versions (please complete the following information):

  • OS: OSX Sonoma 14.2.1
  • K9s: v0.30.8
  • K8s: v1.27.3

Additional context

Results of running k9s --logLevel debug --logFile k9s_0.30.8.log

1:55AM INF 🐶 K9s starting up... 11:55AM DBG Found existing context config: "/Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml" 11:55AM DBG Active Context "test-cluster" 11:55AM INF ✅ Kubernetes connectivity 11:55AM DBG No custom skin found. Using stock skin 11:55AM DBG Factory START with ns "test-ns"
11:55AM DBG Fetching latest k9s rev...
11:55AM DBG K9s latest rev: "v0.30.8"
11:55AM DBG ConfigWatcher watching: "/Users/test_user/Library/Application Support/k9s/config.yaml"
11:55AM DBG ConfigWatcher watching: "/Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml"
11:55AM WRN CustomView watcher failed error="open /Users/test_user/Library/Application Support/k9s/views.yaml: no such file or directory"
11:55AM DBG ConfigWatcher file changed: /Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml -- "WRITE"
11:55AM DBG Found existing context config: "/Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml"
11:55AM DBG ConfigWatcher file changed: /Users/test_user/Library/Application Support/k9s/config.yaml -- "WRITE|CHMOD"
11:55AM DBG No custom skin found. Using stock skin
11:55AM DBG No custom skin found. Using stock skin
11:55AM DBG ConfigWatcher file changed: /Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml -- "WRITE"
11:55AM DBG Found existing context config: "/Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml"
11:55AM DBG ConfigWatcher file changed: /Users/test_user/Library/Application Support/k9s/config.yaml -- "WRITE"
11:55AM DBG ConfigWatcher file changed: /Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml -- "WRITE|CHMOD"
11:55AM DBG Found existing context config: "/Users/test_user/Library/Application Support/k9s/clusters/test-cluster/test-cluster/config.yaml"
11:55AM ERR Boom! runtime error: invalid memory address or nil pointer dereference
11:55AM DBG ConfigWatcher file changed: /Users/test_user/Library/Application Support/k9s/config.yaml -- "WRITE|CHMOD"
11:55AM 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:84 +0x9c
panic({0x106490bc0?, 0x1089b51e0?})
runtime/panic.go:914 +0x218
github.com/derailed/tview.(*Application).Run.func1()
github.com/derailed/[email protected]/application.go:243 +0x4c
panic({0x106490bc0?, 0x1089b51e0?})
runtime/panic.go:914 +0x218
github.com/derailed/k9s/internal/config.(*K9s).ActiveContextNamespace(...)
github.com/derailed/k9s/internal/config/k9s.go:152
github.com/derailed/k9s/internal/config.(*Config).ActiveNamespace(0x14000e4adb0?)
github.com/derailed/k9s/internal/config/config.go:132 +0x28
github.com/derailed/k9s/internal/view.(*Command).run(0x14000e4adb0, 0x14001a87400, {0x0, 0x0}, 0x80?)
github.com/derailed/k9s/internal/view/command.go:139 +0xdc
github.com/derailed/k9s/internal/view.(*App).gotoResource(0x14000b5fc20, {0x1054eadac, 0x4}, {0x0, 0x0}, 0x2?)
github.com/derailed/k9s/internal/view/app.go:688 +0x84
github.com/derailed/k9s/internal/view.(*Namespace).switchNs(0x14001a87558?, 0x105351cf8?, {0x1000002d5?, 0x14000dc8900?}, {{0x14001a875b8, 0x102ce72b8}, {0x14001a87588, 0x1052d0ac0}, {0x14000dbcd60, 0x14001a87540}, ...}, ...)
github.com/derailed/k9s/internal/view/ns.go:46 +0x4c
github.com/derailed/k9s/internal/view.(*Browser).enterCmd(0x14000e56300, 0x14001a876d6?)
github.com/derailed/k9s/internal/view/browser.go:330 +0xe8
github.com/derailed/k9s/internal/view.(*Table).keyboard(0x14000abd280, 0x140004fece0)
github.com/derailed/k9s/internal/view/table.go:90 +0x120
github.com/derailed/k9s/internal/view.(*Browser).InputHandler.(*Table).InputHandler.(*Box).WrapInputHandler.func2(0x14001a87768?, 0x1053cd620?)
github.com/derailed/[email protected]/box.go:179 +0x3c
github.com/derailed/k9s/internal/view.(*PageStack).InputHandler.(*Pages).InputHandler.func1(0x110da3f58?, 0x14000dd3380?)
github.com/derailed/[email protected]/pages.go:332 +0xa8
github.com/derailed/k9s/internal/view.(*PageStack).InputHandler.(*Pages).InputHandler.(*Box).WrapInputHandler.func2(0x14001a877e8?, 0x103f55900?)
github.com/derailed/[email protected]/box.go:182 +0x54
github.com/derailed/tview.(*Flex).InputHandler.func1(0x14001a87878?, 0x4?)
github.com/derailed/[email protected]/flex.go:261 +0xd0
github.com/derailed/tview.(*Flex).InputHandler.(*Box).WrapInputHandler.func2(0x14000dd2810?, 0xeccc?)
github.com/derailed/[email protected]/box.go:182 +0x54
github.com/derailed/k9s/internal/ui.(*Pages).InputHandler.(*Pages).InputHandler.func1(0x10?, 0x106595d60?)
github.com/derailed/[email protected]/pages.go:332 +0xa8
github.com/derailed/k9s/internal/ui.(*Pages).InputHandler.(*Pages).InputHandler.(*Box).WrapInputHandler.func2(0x14001a879e0?, 0x14001a87920?)
github.com/derailed/[email protected]/box.go:182 +0x54
github.com/derailed/tview.(*Application).Run(0x14000238d20)
github.com/derailed/[email protected]/application.go:334 +0x470
github.com/derailed/k9s/internal/view.(*App).Run(0x14000b5fc20)
github.com/derailed/k9s/internal/view/app.go:530 +0x90
github.com/derailed/k9s/cmd.run(0x14000209100?, {0x1054ead04?, 0x4?, 0x1054eac20?})
github.com/derailed/k9s/cmd/root.go:102 +0x40c
github.com/spf13/cobra.(*Command).execute(0x1089e80e0, {0x1400010e060, 0x4, 0x4})
github.com/spf13/[email protected]/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x1089e80e0)
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:59
main.main()
github.com/derailed/k9s/main.go:32 +0x28
`

@derailed
Copy link
Owner

derailed commented Jan 4, 2024

@Loth4r Thanks for reporting this!
I think I see the problem but for good measure could you share you test-cluster config.
Guessing we've either manually edited or created this config file??
Thanks for the additional details here so we can make sure it's resolved...

@wuhaoyujerry
Copy link

I'm running into the same issue.

@aglees
Copy link

aglees commented Jan 5, 2024

Same here on MacOS.

@Loth4r
Copy link
Author

Loth4r commented Jan 5, 2024

@Loth4r Thanks for reporting this! I think I see the problem but for good measure could you share you test-cluster config. Guessing we've either manually edited or created this config file?? Thanks for the additional details here so we can make sure it's resolved...

Thanks for quick response @derailed!. Please find my config file below

k9s:
  cluster: test-cluster
  readOnly: false
  namespace:
    active: all
    lockFavorites: false
    favorites:
    - ns-dev2
    - ns-dev1
    - demo
    - all
    - default
  view:
    active: pods
  featureGates:
    nodeShell: false
  portForwardAddress: localhost

Note that I have not been fiddling around with this file at all. Only thing i did was to update k9s and this issue started to pop up. If this helps -> I maintain k9s via homebrew, tried uninstalling it, clearing /Users/test_user/Library/Application Support/k9s/ folder that stores configuration files, then installing k9s again -> once I do this i see cluster config file gets recreated, but issue still persists. Let me know if I can provide any additional feedback.

@benlindsay
Copy link

Same issue here, also have not been fiddling with config files, but tried clearing out that ~/Library/Application\ Support/k9s folder with no effect.

Is there an easy way to roll back to a previous version of k9s?

@luckmy46
Copy link

luckmy46 commented Jan 5, 2024

I'm running into the same issue.

@derailed
Copy link
Owner

derailed commented Jan 7, 2024

@Loth4r Thanks for the details! I think I've found the issue ;( Fix on the way...

@derailed derailed added bug Something isn't working InProgress Marks an issue has being worked on labels Jan 7, 2024
@cgill27
Copy link

cgill27 commented Jan 7, 2024

I'm not sure if related or not, but on version v0.30.8, if you do k9s --version or any other non-existing cli argument, you will see a go panic

@jduepmeier
Copy link

As a quick fix disable the ConfigWatcher (https://github.com/derailed/k9s/blob/master/internal/ui/config.go#L125).

The problem is a race condition on config reloads. If i understand it correctly a namespace change will be written to the config file. This triggers the watcher and reloads the config back. The config handling is not thread safe.
I think the best way to handle this is to add a mutex for accessing the config.

@benlindsay
Copy link

benlindsay commented Jan 8, 2024

As a quick fix disable the ConfigWatcher (https://github.com/derailed/k9s/blob/master/internal/ui/config.go#L125).

Thanks! Can you give us some pointers on how to disable that? Do we need to comment out some code and compile locally or is that something we can do at the config or CLI level?

Also, in the meantime would someone be able to roll back the k9s version on homebrew?

@polinchw
Copy link

polinchw commented Jan 8, 2024

Same issue on Mac.

@edwardccg
Copy link

edwardccg commented Jan 8, 2024

Had the same issue after upgrading via Homebrew for Mac. I can't seems to install older version via @ version either. Looks like i have to manually download the older binary from release and run it ?

derailed added a commit that referenced this issue Jan 9, 2024
derailed added a commit that referenced this issue Jan 9, 2024
derailed added a commit that referenced this issue Jan 9, 2024
derailed added a commit that referenced this issue Jan 9, 2024
* [Bug] Fix #2428

* [Bug] Ensures primordials configs are gen/saved if not present

* v0.31.1 release notes
derailed added a commit that referenced this issue Jan 9, 2024
derailed added a commit that referenced this issue Jan 9, 2024
* [Bug] Fix #2428

* fix #2446

* fix #2449

* schemas updates

* Add debug info

* v0.31.2 rel notes
@Loth4r
Copy link
Author

Loth4r commented Jan 10, 2024

I can confirm this got solved for me after upgrading to v0.31.1. Thanks for the support @derailed!

@psytechno604
Copy link

This still happens in v0.31.3 if KUBECONFIG env is not set

thejoeejoee pushed a commit to thejoeejoee/k9s that referenced this issue Feb 23, 2024
* cleaning up

* [Bug] Fix derailed#2425 - no context skin issue

* [Bug] Fix derailed#2428

* [Feat] schema validation

* v0.31.0 Release notes
thejoeejoee pushed a commit to thejoeejoee/k9s that referenced this issue Feb 23, 2024
* [Bug] Fix derailed#2428

* [Bug] Ensures primordials configs are gen/saved if not present

* v0.31.1 release notes
thejoeejoee pushed a commit to thejoeejoee/k9s that referenced this issue Feb 23, 2024
* [Bug] Fix derailed#2428

* fix derailed#2446

* fix derailed#2449

* schemas updates

* Add debug info

* v0.31.2 rel notes
placintaalexandru pushed a commit to placintaalexandru/k9s that referenced this issue Apr 3, 2024
* cleaning up

* [Bug] Fix derailed#2425 - no context skin issue

* [Bug] Fix derailed#2428

* [Feat] schema validation

* v0.31.0 Release notes
placintaalexandru pushed a commit to placintaalexandru/k9s that referenced this issue Apr 3, 2024
* [Bug] Fix derailed#2428

* [Bug] Ensures primordials configs are gen/saved if not present

* v0.31.1 release notes
placintaalexandru pushed a commit to placintaalexandru/k9s that referenced this issue Apr 3, 2024
* [Bug] Fix derailed#2428

* fix derailed#2446

* fix derailed#2449

* schemas updates

* Add debug info

* v0.31.2 rel notes
@diegoulloao
Copy link

happening in macOs 0.32.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working InProgress Marks an issue has being worked on
Projects
None yet
Development

No branches or pull requests