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

Favorite namespaces not limited to 9 in cluster config file #2978

Open
assert-0 opened this issue Nov 20, 2024 · 0 comments
Open

Favorite namespaces not limited to 9 in cluster config file #2978

assert-0 opened this issue Nov 20, 2024 · 0 comments

Comments

@assert-0
Copy link




Describe the bug

In the file ~/.local/share/k9s/clusters/[cluster]/[context]/config.yaml, there is a favorites list of the user's favorite namespaces. On the latest version of k9s (currently v0.32.7), this list is automatically filled with namespaces that the user visits, and it is limited to 9 items. However, in older versions of k9s, this wasn't enforced and the list could grow beyond 9 items. In those older versions, this resulted in bugs that prevented the user from being able to select multiple pods using CTRL + SPACE. The related issue is this one, and this is the pull request. The CTRL + SPACE bug is now resolved by the pull request.

However, there is still an inconsistency present in the code: when installing the latest k9s version, old cluster config files are still loaded as normal, even though they might contain more than 9 namespaces in the favorites section. In v0.32.7, when such a config file is loaded, the CTRL + SPACE bug does not happen, but when the cluster's config file is saved, it still contains more than 9 favorite namespaces. I believe this is inconsistent with k9s' invariants and that the favorite namespaces list should automatically be capped to 9 immediately upon loading the file, as well as when saving it again.

If the maintainers agree that this should be the expected behavior, I would like to claim this issue and resolve it in a pull request myself. The reason why I'm asking is because I need it for a school project, and because I actually use k9s a lot, so being able to contribute to the project is interesting to me, even if it's only a small fix such as this one.

To Reproduce

  1. Connect to a cluster with 10 or more namespaces using an old k9s version (e.g. v0.32.5 or older)
  2. Randomly enter and exit namespaces until more than 9 are accumulated in the config file (unfortunately, I haven't discovered how exactly this happens, but it will happen after some trial and error and it was fixed in the latest version anyway)
  3. Reload k9s (still v0.32.5) and confirm that now CTRL + SPACE doesn't work in pods
  4. Upgrade to latest k9s (v0.32.7, also tested with latest master, commit SHA 6b5d24f5741a1789fb97ba3e11f0ee868d93459d)
  5. Randomly enter and exit namespaces again -> CTRL + SPACE will now work in pods
  6. Checking the cluster config file, you will see that it still contains more than 9 namespaces in the favorites list

Expected behavior

The favorite namespaces list in the cluster config file should be reset to at most 9 namespaces after being opened by the latest k9s version.

Versions (please complete the following information):

  • OS: [Pop!_OS 22.04 LTS (Linux 6.9.3)]
  • K9s: [v0.32.7]
  • K8s: [v1.31.2]
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

No branches or pull requests

1 participant