Skip to content
This repository was archived by the owner on Oct 3, 2026. It is now read-only.

test(differ): poll for async loop detach in checkNoLoopDevice - #46

Closed
aledbf wants to merge 1 commit into
mainfrom
fix/checknoloopdevice-async-detach
Closed

aledbf wants to merge 1 commit into
mainfrom
fix/checknoloopdevice-async-detach

Conversation

@aledbf

@aledbf aledbf commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

checkNoLoopDevice did a single immediate FindByBackingFile check right after the temp-mount cleanup returned. The kernel releases loop devices asynchronously after LOOP_CLR_FD / autoclear, so a backing file can still resolve to a device for a short window after cleanup — causing flaky failures:

loop device /dev/loop1 still attached to .../layer.erofs

Observed in TestWithStackedErofsTempMount and TestWithActiveSnapshotMountOverlay (root tests).

Fix

Poll with a 5s deadline, matching the existing helpers that already handle the same race:

  • mountutils/erofs_linux_test.go:verifyNoLoopDevice
  • loop/loop_linux_test.go:verifyDetached

Both already document "the kernel may release loop devices asynchronously" and poll. This makes checkNoLoopDevice consistent.

Test-only change; no production code touched.

Testing

  • GOOS=linux go vet ./internal/differ/ — clean
  • task lint — 0 issues
  • Root tests not run on the dev box (darwin); the change only adds polling to an existing assertion.

🤖 Generated with Claude Code

checkNoLoopDevice did a single immediate FindByBackingFile check after
the temp mount cleanup returned. The kernel releases loop devices
asynchronously after LOOP_CLR_FD / autoclear, so the backing file can
still resolve to a device for a short window, causing flaky failures:

  loop device /dev/loop1 still attached to .../layer.erofs

(seen in TestWithStackedErofsTempMount and TestWithActiveSnapshotMountOverlay)

Poll with a 5s deadline, matching the existing mountutils.verifyNoLoopDevice
and loop.verifyDetached helpers, which already handle the same race.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aledbf

aledbf commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #45.

@aledbf aledbf closed this Jun 15, 2026
@aledbf
aledbf deleted the fix/checknoloopdevice-async-detach branch June 15, 2026 21:52
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant