fix(runner): preserve target repo directory inode during extraction#3381
fix(runner): preserve target repo directory inode during extraction#3381ralphbean wants to merge 3 commits into
Conversation
Replace os.RemoveAll(hostRepositoryDir) with clearDirContents(), which removes all entries inside the directory without removing the directory itself. This preserves the directory inode so that shells whose CWD points at the target repo continue to work after extraction. Previously, the delete-then-recreate cycle would orphan any shell sitting in the directory, causing subsequent commands to fail with "getwd: no such file or directory". Also adds a StepInfo log line showing the full absolute path being cleared, making it obvious what happened if something goes wrong. Relates-to: #2075 Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ralph Bean <rbean@redhat.com>
PR Summary by Qodofix(runner): preserve target repo directory inode during extraction
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
🤖 Finished Review · ✅ Success · Started 4:15 PM UTC · Completed 4:24 PM UTC |
Site previewPreview: https://a3e5d419-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Code Review by Qodo
1.
|
Review — PR #3381Verdict: approve ✅ Re-review note: The new commit (be97fb1) adds edge-case sub-tests for Clean, well-scoped fix for the inode invalidation that causes Correctness
Security
Intent & scope
Style
Documentation
Previous runReview — PR #3381Verdict: approve ✅ Re-review note: The new commit (78963a0) is a merge resolving conflicts with main in Clean, well-scoped fix for the inode invalidation that causes Correctness
Security
Intent & scope
Style
Documentation
Previous runReview — PR #3381Verdict: approve ✅ Clean, well-scoped fix for the inode invalidation that causes Security notes
ObservationsRemaining race window (relates to #2075): The linked issue describes both inode invalidation and a race condition where concurrent readers see an empty/partial directory during the clear→extract window. This PR fixes the inode problem but the atomicity concern remains — the directory goes through an empty state between Test edge cases: The test covers the happy path well (files + subdirectory removed, inode preserved). Consider adding sub-tests for: (1) an empty directory (documents the no-op case), and (2) a non-existent directory (documents the error contract, which differs from Labels: PR modifies runner CLI code (internal/cli/run.go) with a bug fix for inode preservation Previous runReview — PR #3381Verdict: approve ✅ Re-review note: The new commit (78963a0) is a merge resolving conflicts with main in Clean, well-scoped fix for the inode invalidation that causes Correctness
Security
Intent & scope
Style
Documentation
Previous run (2)Review — PR #3381Verdict: approve ✅ Clean, well-scoped fix for the inode invalidation that causes Security notes
ObservationsRemaining race window (relates to #2075): The linked issue describes both inode invalidation and a race condition where concurrent readers see an empty/partial directory during the clear→extract window. This PR fixes the inode problem but the atomicity concern remains — the directory goes through an empty state between Test edge cases: The test covers the happy path well (files + subdirectory removed, inode preserved). Consider adding sub-tests for: (1) an empty directory (documents the no-op case), and (2) a non-existent directory (documents the error contract, which differs from Labels: PR modifies runner CLI code (internal/cli/run.go) with a bug fix for inode preservation |
Both branches added independent test functions at the end of internal/cli/run_test.go. Keep both: TestClearDirContents from this branch and the config/backend/allowlist tests from main. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ralph Bean <rbean@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 12:17 PM UTC · Completed 12:25 PM UTC |
Add sub-tests for empty directory (no-op) and non-existent directory (returns error) to document the function's contract. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ralph Bean <rbean@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 8:00 PM UTC · Completed 8:09 PM UTC |
Summary
os.RemoveAll(hostRepositoryDir)withclearDirContents()which removes directory contents but preserves the directory itself (and its inode)fullsend runa second time from the same shellStepInfolog line showing the full absolute path being clearedProblem
When running
fullsend run ... --target-repo . --fullsend-dir ., the extraction step (os.RemoveAll+SafeDownload) deletes and recreates the target repo directory. This destroys the directory inode, orphaning any shell whose CWD pointed at it. The next invocation from that shell fails immediately:Fix
clearDirContents()iterates over directory entries and removes them individually, leaving the directory itself (and its inode) intact. Shells continue to work without needingcd ..Relates-to: #2075
Test plan
TestClearDirContentsverifies inode preservation and content removalfullsend runtwice from the same shell with--target-repo .— second invocation should work withoutcd .🤖 Generated with Claude Code