fix: running parallel bundle submits no longer clobbers config file #444
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #386
What was the problem/requirement? (What/Why)
The customer reports that the config file can get clobbered when running many bundle submit commands in parallel. When clobbered, the config file will only contain the job-id for the a submitted job; all of the farm, queue, etc information will be gone.
What was the solution? (How)
A standard pattern for concurrent file modification is to write changes to a temp file, and then move that temp file overtop of the config file via a filesystem rename operation. The rename is atomic, so that prevents the file content from being clobbered.
What is the impact of this change?
How was this change tested?
The unit tests already covered all required cases. Importantly, there are already tests that verify that the file permissions of the config file is correctly set, and those still pass.
Was this change documented?
None required.
Is this a breaking change?
No. No public interfaces change.
Does this change impact security?
Yes, this does impact security as it affects how the configuration file is created. However, tests already exist to ensure that the files are created with the correct permissions, and those pass just fine.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.