Repository navigation
[QUALITY-1958] Use unique temp files when writing git credential stores - #16653
Draft
ericli-warp wants to merge 1 commit into
Draft
ericli-warp wants to merge 1 commit into
ericli-warp wants to merge 1 commit into
Conversation
Concurrent runs on one direct-backend worker host share HOME and the gh config directory. The .git-credentials, gh hosts.yml, and glab config writers each used a fixed temp name, so one run could rename another run's temp file away and fail with "No such file or directory". Write through a uniquely named temp file instead, reusing the pattern the Azure token writer already used. Co-Authored-By: Warp <agent@warp.dev>
|
@ericli-warp, your GitHub account is not connected to Warp. Connect your GitHub account. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes intermittent
Skill resolution failed: Failed to write git credentials before skill resolution: Failed to rename …/hosts.yml.tmp to …/hosts.yml: No such file or directorywhen several Oz runs start at the same time on one direct-backend worker host. Those runs shareHOMEand the gh config directory. The.git-credentials, ghhosts.yml, and glabconfig.ymlwriters each used a fixed temp name, so one run could rename another run's temp file away before that run's own rename.Each write now goes through
replace_secret_file: it creates a uniquely named 0600 temp file in the target directory, fsyncs it, and persists it over the target.write_azure_cli_tokenalready used this pattern, so it now calls the helper too. File contents are unchanged. Docker, Kubernetes, and Namespace tasks have their own filesystems and never hit the race.Side effects of the change:
*.tmppath..hosts.yml.tmp-XXXXXXfile behind. Normal error paths delete it.Out of scope:
.git-credentialsis still read, merged, and written. Concurrent runs that receive different host sets can still overwrite each other's entries (last writer wins). Runs that receive the same hosts, such as benchmark trials for one factory, are unaffected.I found this while running Factory benchmark trials on the oz-local direct backend. In the driver log, several trials wrote credentials within the same second and one of them failed.
Linked Issue
QUALITY-1958
ready-to-specorready-to-implement. (Linear ticket, not a GitHub issue.)Testing
New regression test
concurrent_credential_store_writes_share_directories_safelyruns 8 threads that each write all three stores into one shared home directory 25 times. It failed against the previous code with the same rename error, and it passes with this change.The gh and glab filename tests now assert that the config directory contains only the target file, which catches a leftover temp file of any name.
cargo nextest run -p warp -E 'test(/git_credentials::tests::/)': 42 passed.cargo clippy -p warp --all-targets --tests -- -D warnings: clean. Both ran on macOS only.I have manually tested my changes locally with
./script/run(not run end to end. The end-to-end check is a multi-trial benchmark run on the oz-local direct backend with a rebuilt binary.)Agent Mode
Conversation: https://staging.warp.dev/conversation/0415f6a5-02e4-471c-8710-6942fcdbd340
CHANGELOG-BUG-FIX: Fixed Oz runs on self-hosted direct-backend workers sometimes failing at startup with "Failed to write git credentials" when several runs start at the same time.