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

/tmp/k3s-releases.yaml #547

Open
jampy opened this issue Feb 18, 2025 · 4 comments
Open

/tmp/k3s-releases.yaml #547

jampy opened this issue Feb 18, 2025 · 4 comments

Comments

@jampy
Copy link

jampy commented Feb 18, 2025

Not a big issue, but the cache file name /tmp/k3s-releases.yaml appears to be hardcoded in hetzner-k3s

This could lead to problems on a machine where hetzner-k3s is used by multiple system users. Once user A used hetzner-k3s one time (creating /tmp/k3s-releases.yaml), any other system user won't be able to refresh the file since it is writeable exclusively for user A.

I did not run into any errors yet, but think that in theory this could lead into problems sooner or later, especially when user A stops running hetzner-k3s.

@vitobotta
Copy link
Owner

Hi,

The file path needs to be consistent, so hetzner-k3s can locate the cached version every time it runs. The file gets automatically refreshed by the tool if it's older than 7 days, by the way. Check out the code for details: https://github.com/vitobotta/hetzner-k3s/blob/main/src/k3s.cr#L11-L17.

If you still feel the file's location is an issue, even with the auto-refresh, where would you suggest storing it?

@jampy
Copy link
Author

jampy commented Feb 18, 2025

I'm not sure if I've described the problem well.

An example:

  • system user foo uses hetzner-k3s to create the cluster alpha. The tool creates /tmp/k3s-releases.yaml with mode 0644 and owner foo. So far, all good.
  • a few weeks/months later, the system user bar also uses hetzner-k3s to create the cluster beta. The hetzner-k3s tool tries to update /tmp/k3s-releases.yaml but fails (maybe silently, I don't know) since it has no write access to the file that's owned by foo.

My suggestion would be to use a file name that is not shared with other system users, like...

  • /tmp/hetzner-k3s-{foo,bar}/k3s-releases.yaml (like mc or podman do)
  • /tmp/k3s-releases-{foo,bar}.yaml
  • ~/.hetzner-k3s/k3s-releases.yaml (like ssh, k3s, ...)

... you get the idea

@vitobotta
Copy link
Owner

OK, I can add the current user to the file name. Note taken.

@vitobotta
Copy link
Owner

Actually I like the last suggestion for the home directory better.

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

2 participants