test(core): wait out ETXTBSY before running the fake container CLI - #2522
Merged
Merged
Conversation
FakeCli writes a shell script and then executes it. Tests run on parallel threads, and a child forked by another test while fs::write had the script open inherits that write descriptor until it execs; executing the script in that window fails with 'Text file busy (os error 26)'. Seen as a CI failure of a_missing_image_fails_without_retrying. Run the script once right after writing it, retrying while it reports ExecutableFileBusy. Once that succeeds nothing can hold a writable descriptor to it again.
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.
Summary
container_image::tests::a_missing_image_fails_without_retryingfailed in CI on #2521 with:The
FakeClifixture added in #2516 writes a shell script and then executes it. Tests run on parallel threads. A child process forked by another test whilefs::writestill had the script open inherits that write descriptor, and holds it until the child calls exec. If our test executes the script in that window, it fails withETXTBSY. It's a race in the test fixture; the production pull code is fine.Change
Right after writing the script,
FakeCli::newruns it once and retries (5ms apart, up to 1s) while that fails withErrorKind::ExecutableFileBusy. Once one run succeeds, no process can hold a writable descriptor to the script again, so the real calls can't hit the race. The probe's line incalls.logis removed so call assertions are unchanged.Test plan
cargo test -p fakecloud-core container_image: 17 passcargo clippy -p fakecloud-core --all-targets -- -D warnings: cleanNo non-code surface affected.
Summary by cubic
Fixes a flaky failure in the fake container CLI test fixture where a test could fail with
Text file busy (os error 26)when another parallel test's child process still held the script open for writing.FakeCli::newnow runs the script once right after writing it, retrying while it getsExecutableFileBusy, guaranteeing no process can later hold a writable descriptor. The probe run's line is removed fromcalls.logso call assertions are unchanged.Written for commit dbe6565. Summary will update on new commits.