Skip to content

Commit c90b3be

Browse files
authored
Try to unmount compiler shards a little bit more (#111)
1 parent 4b145ee commit c90b3be

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/Rootfs.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,23 +305,29 @@ so will error out if something goes awry. Note that this function only does
305305
something when using a squashfs shard on Linux. All other combinations of
306306
shard archive type and platform result in a no-op.
307307
"""
308-
function unmount(cs::CompilerShard, build_prefix::String; verbose::Bool = false, fail_on_error::Bool = false)
308+
function unmount(cs::CompilerShard, build_prefix::String; verbose::Bool = false, fail_on_error::Bool = false, tries::Int = 3)
309309
# Only try to unmount if it's mounted
310310
if Sys.islinux() && is_mounted(cs, build_prefix)
311311
mpath = mount_path(cs, build_prefix)
312312
if verbose
313313
@debug("Unmounting $(mpath)`")
314314
end
315-
try
316-
cmd = `$(sudo_cmd()) umount $(mpath)`
317-
run(cmd, verbose ? (devnull, stdout, stderr) : (devnull, devnull, devnull))
318-
319-
# Remove mountpoint directory
320-
rm(mpath; force=true, recursive=false)
321-
catch e
322-
# By default we don't error out if this unmounting fails
323-
if e isa InterruptException || fail_on_error
324-
rethrow(e)
315+
# Try to unmount a few times
316+
for ntry in 1:tries
317+
try
318+
cmd = `$(sudo_cmd()) umount $(mpath)`
319+
run(cmd, verbose ? (devnull, stdout, stderr) : (devnull, devnull, devnull))
320+
321+
# Remove mountpoint directory
322+
rm(mpath; force=true, recursive=false)
323+
break
324+
catch e
325+
# By default we don't error out if this unmounting fails
326+
if e isa InterruptException || fail_on_error
327+
rethrow(e)
328+
end
329+
@info("Couldn't unmount $(mpath), trying again...")
330+
sleep(0.1)
325331
end
326332
end
327333
end

0 commit comments

Comments
 (0)