fix: make unmount handling robust for busy/disconnected mounts - #772
fix: make unmount handling robust for busy/disconnected mounts#772qinfustu wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #772 +/- ##
==========================================
+ Coverage 25.42% 26.29% +0.87%
==========================================
Files 133 134 +1
Lines 12639 12888 +249
==========================================
+ Hits 3213 3389 +176
- Misses 9036 9088 +52
- Partials 390 411 +21
🚀 New features to boost your workflow:
|
4c51cb0 to
9a35551
Compare
|
The force/lazy fallback needs a call from the maintainers, because
Two smaller ones:
|
Overview
Make
mount.Umount(andWaitUntilUnmounted) robust against busy anddisconnected mountpoints, so stale
nydusdFUSE mounts are always torn downinstead of being left behind.
Related Issues
Related #771
Change Details
Previously
Umounthad two problems that leave residual mountpoints underregistry pressure / after a nydusd crash:
ENOTCONN. When the backing nydusd is dead, the FUSE mountbecomes disconnected and
IsMountpoint(viaos.Stat) fails withENOTCONN.The old code returned that error and never even attempted to unmount — i.e.
the mountpoint that most needs cleaning up was skipped.
EBUSY.syscall.Unmount(target, 0)had nofallback, so a busy mountpoint (old process still holding it) was left mounted.
Changes:
Umountnow treats anENOTCONN/ESTALEmountpoint as "needs unmount" andproceeds instead of returning early; a genuinely-not-mounted path now returns
nil(previously returned a misleading"not mounted"error).unmountWithFallback: plain unmount →MNT_FORCE(abort in-flight FUSErequests) →
MNT_DETACH(lazy detach for busy mounts).EINVALis treated asalready unmounted.
WaitUntilUnmountedno longer reports a disconnected mountpoint as an error(it would otherwise spin for ~1s and log a misleading failure during teardown).
MNT_FORCE/MNT_DETACHare platform-specific, so they live inmount_linux.go/mount_darwin.go(darwin has no lazy detach and degrades toforce; that build exists only for local dev — nydusd mounts are Linux-only at
runtime).
syscallUnmount,isMountpoint) to enable unit tests.The only production caller of
mount.Mounter.Umountisdaemon.ClearVestige, sothe blast radius is small.
Test Results
New unit tests in
pkg/utils/mount/mount_test.go:TestIsDisconnected—ENOTCONN/ESTALEdetection, including throughpkg/errorswrapping.TestUnmountWithFallback— plain success,EINVALshort-circuit,EBUSY → force,force → lazy detach, and all-fail returns error.TestUmount— disconnected mount still unmounts; non-mountpoint returns nilwithout unmounting; other errors propagate.
TestWaitUntilUnmountedIgnoresDisconnectedMountpoint— disconnected mountreturns immediately without retrying.
Change Type
Please select the type of change your pull request relates to:
Self-Checklist
Before submitting a pull request, please ensure you have completed the following: