fix(sharness): no blocking on unclean FUSE unmount (#10906)
this is rare, but if someone runs a lot of tests and had some unrelated FUSE failures, sharness can get stuck on lsof step. this ensures we never get stuck + there is more visibility so people who care about FUSE have better time debugging
Marcin Rataj committed
Aug 11, 2025 at 21:45 UTC
c08e24b8138a2c6293dc927d1a83126e113c28c3
1 file changed
+30
-3
test/sharness/lib/test-lib.sh
+30
-3
@@ -54,7 +54,7 @@ cur_test_pwd="$(pwd)"
54
while true ; do
55
echo -n > stuck_cwd_list
56
57
- lsof -c ipfs -Ffn 2>/dev/null | grep -A1 '^fcwd$' | grep '^n' | cut -b 2- | while read -r pwd_of_stuck ; do
57
+ timeout 5 lsof -c ipfs -Ffn 2>/dev/null | grep -A1 '^fcwd$' | grep '^n' | cut -b 2- | while read -r pwd_of_stuck ; do
58
case "$pwd_of_stuck" in
59
"$cur_test_pwd"*)
60
echo "$pwd_of_stuck" >> stuck_cwd_list
@@ -309,10 +309,37 @@ test_launch_ipfs_daemon_without_network() {
309
}
310
311
do_umount() {
312
+ local mount_point="$1"
313
+ local max_retries=3
314
+ local retry_delay=0.5
315
+
316
+ # Try normal unmount first (without lazy flag)
317
+ for i in $(seq 1 $max_retries); do
318
+ if [ "$(uname -s)" = "Linux" ]; then
319
+ # First attempt: standard unmount
320
+ if fusermount -u "$mount_point" 2>/dev/null; then
321
+ return 0
322
+ fi
323
+ else
324
+ if umount "$mount_point" 2>/dev/null; then
325
+ return 0
326
+ fi
327
+ fi
328
+
329
+ # If not last attempt, wait before retry
330
+ if [ $i -lt $max_retries ]; then
331
+ go-sleep "${retry_delay}s"
332
+ fi
333
+ done
334
+
335
+ # If normal unmount failed, try lazy unmount as last resort (Linux only)
336
if [ "$(uname -s)" = "Linux" ]; then
313
- fusermount -z -u "$1"
337
+ # Log that we're falling back to lazy unmount
338
+ test "$TEST_VERBOSE" = 1 && echo "# Warning: falling back to lazy unmount for $mount_point"
339
+ fusermount -z -u "$mount_point" 2>/dev/null
340
else
315
- umount "$1"
341
+ # On non-Linux, try force unmount
342
+ umount -f "$mount_point" 2>/dev/null || true
343
fi
344
}
345