15937: Suppress errors from fusermount unless mount still exists.
authorTom Clegg <tom@tomclegg.ca>
Tue, 7 Jan 2020 19:30:16 +0000 (14:30 -0500)
committerTom Clegg <tom@tomclegg.ca>
Tue, 7 Jan 2020 19:30:16 +0000 (14:30 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

services/fuse/arvados_fuse/unmount.py

index a72da3a8dcae93a0699cf79f4e0d65c97438ce03..1f06d8c91cf21608e02ddab7ae3bdd63d8ee45f2 100644 (file)
@@ -116,6 +116,7 @@ def unmount(path, subtype=None, timeout=10, recursive=False):
 
     was_mounted = False
     attempted = False
+    fusermount_output = b''
     if timeout is None:
         deadline = None
     else:
@@ -155,6 +156,10 @@ def unmount(path, subtype=None, timeout=10, recursive=False):
             return was_mounted
 
         if attempted:
+            # Report buffered stderr from previous call to fusermount,
+            # now that we know it didn't succeed.
+            sys.stderr.write(fusermount_output)
+
             delay = 1
             if deadline:
                 delay = min(delay, deadline - time.time())
@@ -172,6 +177,10 @@ def unmount(path, subtype=None, timeout=10, recursive=False):
 
         attempted = True
         try:
-            subprocess.check_call(["fusermount", "-u", "-z", path])
-        except subprocess.CalledProcessError:
-            pass
+            subprocess.check_output(
+                ["fusermount", "-u", "-z", path],
+                stderr=subprocess.STDOUT)
+        except subprocess.CalledProcessError as e:
+            fusermount_output = e.output
+        else:
+            fusermount_output = b''