Fix race condition in config handling (v7) #2936
Merged
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.
Description of the Change
The CLI encounters race conditions when handling config files if multiple commands are executed in parallel.
Currently, the CLI writes a new config for every command executed due to the code in command_parser.go. However, it also deletes all temporary config files when reading the config, leading to race conditions between multiple processes. This PR introduces two changes to mitigate this problem:
cli/util/configv3/write_config.go
Lines 63 to 66 in 04df8ae
Why Is This PR Valuable?
Enables usage of the CF CLI in scripts which execute commands in parallel
Applicable Issues
fixes #2232
How Urgent Is The Change?
Medium
Other Relevant Parties
Anyone using the CLI in scripts with parallel execution. Multiple users have encountered this issue, as discussed in #2232.
Related PRs