-
Notifications
You must be signed in to change notification settings - Fork 21
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
motdgen, issuegen: write staged changes to a tempfile #44
motdgen, issuegen: write staged changes to a tempfile #44
Conversation
88dab77
to
c15a140
Compare
a88708f
to
0a5346c
Compare
It's too bad bash doesn't expose But still though aren't there going to be races since we're still truncating and replacing files that the main issuegen process will re-read? In other words don't we want to do something like "write to a file ending in .tmp, rename() into place", and ensure that issuegen ignores files ending in ".tmp" or so? (Which sadly we still need to do even with |
I think you're right - it's still possible for the writes to the intermediate snippets going into issuegen/motdgen to overstep each other. I'll take a look at Also having doubts with the current change in this PR - redirection |
0a5346c
to
6afc0a4
Compare
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
e446583
to
8fedbd3
Compare
Updated to use Working on a make target to allow more easily testing this - should be up soon. |
Now ready for review! The Makefile and sync_to_vm.sh script in #57 can be used to test, if anyone would like to test the changes locally. |
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.
LGTM
I have also test run these changes locally using https://github.com/coreos/console-login-helper-messages/blob/master/README-devel.md#testing-changes-in-a-virtual-machine and #44 (comment)
(somewhat superficial since I don't know this code) LGTM |
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.
LGTM
I found #64 while looking into this change, but this particular change doesn't help or hurt that issue. I say let's go with it. |
For the same reason as in #39
(copying the phrasing below):
With the
staged
file shared, there would be potential for two ormore processes executing
motdgen
to write to it resulting incorrupted output, or the error in the
cat
command due to missingfile reported in #35 (comment). Currently, this is not a problem with
motdgen, but could be if
motdgen
were invoked by something like theudev rules that invoke
issuegen
.Instead, write the intermediate output to a variable before writing
to the final output file. This ensures only valid output is written
to the issue file shown to the terminal.
Additionally, perform code tidyups similar to those done for
issuegen
in #40.