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

config: copy go's file lock and use it instead of client-go's #5982

Merged
merged 2 commits into from
Dec 20, 2022

Conversation

nicksieger
Copy link
Member

Fixes #4814.

Signed-off-by: Nick Sieger [email protected]

@nicksieger nicksieger force-pushed the file-locking-4814 branch 2 times, most recently from a5137c0 to 92f55e6 Compare November 30, 2022 22:45
Copy link
Member

@nicks nicks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat! were you able to reproduce the lock failure?


func init() {
// We're using our own file locking mechanism
clientcmd.UseModifyConfigLock = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think my big concern with this is that it's global state.

it assumes you've updated all the call sites.

i'm not at all confident you've updated all the call sites (particularly the ones in our dependencies)

i'd honestly be more comfortable with a patched version of client-go that uses our locking mechanism. (we already patch apimachinery)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not ideal and could be easily overlooked if we started expanding the ways in which Tilt handles kubeconfigs. In this case, the only place in Tilt where we write config with client-go is the 2 places in this PR in the hud server controller package. I added read locks in places where we read the same config but client-go already didn't try to achieve read consistency, so those aren't strictly necessari. I could move all code dealing with reading and writing Tilt's kubeconfig to a separate package if you think that would help with the maintenance issues.

As it is, I consider this PR to be a temporary band-aid that should be fixed once Go has a public file locking API, at which point we or someone would send a PR to client-go to change the global. Realizing too that "temporary" fixes often become long-term ones, I feel that this change is worthwhile given the lower amount of maintenance we do on Tilt, the point above on how we only have two locations (in the same package) that do writes and the fact that write collisions on kubeconfigs in a dev environment are pretty unlikely.

@nicksieger
Copy link
Member Author

I've seen it from time to time, never consistently. Recent report in slack made me realize that it's probably Tilt getting killed by some other process and the I/O of the HUD server de-registering itself is probably a convenient place for the process to pause, get killed and fail to delete the lock file.

@nicksieger
Copy link
Member Author

Still going to do some sanity check manual testing on Mac, Windows and Linux before merging this. Let me know if you have any more thoughts about the client-go global state issue.

@nicks
Copy link
Member

nicks commented Dec 5, 2022

nope, no further thoughts, LGTM

@nicksieger nicksieger merged commit e0ab3f6 into tilt-dev:master Dec 20, 2022
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 this pull request may close these issues.

Error: writing tilt api configs: open /home/$USER/.tilt-dev/config.lock: file exists
2 participants