-
Notifications
You must be signed in to change notification settings - Fork 370
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
Write manifests atomically #1816
Conversation
ea9d943
to
4b79598
Compare
8f196de
to
c405942
Compare
(It is unclear to me why GitHub isn't removing already merged commits from a PR, but enforces a rebase.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick on some func naming, otherwise LGTM
Turned into draft. Will revisit that, but not right now. |
The PR is marked as stale since no activity has been recorded in 30 days |
The PR is marked as stale since no activity has been recorded in 30 days |
831b439
to
936ed3a
Compare
@jnummelin Revisited this one. Removed the renameio lib as it was a bit awkward to use with its strong emphasis on "this is posix only". Doing this ourselves allows us to implement a different naming scheme for the temp files, getting rid of all that dotted prefix complexity. Renameio has quite some knobs, but none for the temporary file name pattern. |
Use a temporary-write-and-rename approach to write manifests to disk, so that the appliers never see partially written files. The strategy is as follows: Create a temporary file in the same directory as the target, write to it, sync and close the file handle, do a chmod and a rename. As a result, there's no more need to ignore chmod events in the stack applier. Those events actually *can* matter, when files become readable or unreadable for the k0s process. Signed-off-by: Tom Wieczorek <[email protected]>
936ed3a
to
8ea5626
Compare
https://github.com/natefinch/atomic does something similar, worth using? The only drawback I see is that you can't explicitly specify the file mode. |
That's interesting. That lib uses The docs on the write through flag say:
So I doubt that this gives much extra benefit. I already experimented with renameio in this PR, and I eventually concluded that it's easiest to do this on our own. In the end, this gives us all the possibilities, i.e. influence where the temp files are stored and how they are named, change file permissions and so on. Both libs don't offer all of those knobs. |
Description
Part of #1814.
Use a temporary-write-and-rename approach to write manifests to disk, so that the appliers never see partially written files. The strategy is as follows: Create a temporary file in the same directory as the target, write to it, sync and close the file handle, do a chmod and a rename. As a result, there's no more need to ignore chmod events in the stack applier. Those events actually can matter, when files become readable or unreadable for the k0s process.
Type of change
How Has This Been Tested?
Checklist: