This is an automated email from the ASF dual-hosted git repository.

gilbert pushed a commit to branch 1.4.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit dadb7cd9a1af9e0b80cdbef8ee6dbcef9c7fec9a
Author: Jie Yu <yujie....@gmail.com>
AuthorDate: Fri Aug 31 22:29:41 2018 -0700

    Made aufs backend destroy more robust.
    
    Use MNT_DETACH for `unmount` so that if there are still processes
    holding files or directories in the rootfs (e.g., regular filesystem
    indexing), the unmount will still be successful. The kernel will cleanup
    the mount when the number of references reach zero. Also, do not return
    hard failure if `rmdir` failed. It's also possible that `rmdir` returns
    EBUSY. See more details in MESOS-9196.
    
    Review: https://reviews.apache.org/r/68595/
    (cherry picked from commit 8715f135376719613276130f3e3af3b244ff06ee)
---
 .../mesos/provisioner/backends/aufs.cpp              | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/slave/containerizer/mesos/provisioner/backends/aufs.cpp 
b/src/slave/containerizer/mesos/provisioner/backends/aufs.cpp
index 53ccbd1..2f082ac 100644
--- a/src/slave/containerizer/mesos/provisioner/backends/aufs.cpp
+++ b/src/slave/containerizer/mesos/provisioner/backends/aufs.cpp
@@ -251,8 +251,11 @@ Future<bool> AufsBackendProcess::destroy(
 
   foreach (const fs::MountInfoTable::Entry& entry, mountTable->entries) {
     if (entry.target == rootfs) {
-      // NOTE: This would fail if the rootfs is still in use.
-      Try<Nothing> unmount = fs::unmount(entry.target);
+      // NOTE: Use MNT_DETACH here so that if there are still
+      // processes holding files or directories in the rootfs, the
+      // unmount will still be successful. The kernel will cleanup the
+      // mount when the number of references reach zero.
+      Try<Nothing> unmount = fs::unmount(entry.target, MNT_DETACH);
       if (unmount.isError()) {
         return Failure(
             "Failed to destroy aufs-mounted rootfs '" + rootfs + "': " +
@@ -261,9 +264,16 @@ Future<bool> AufsBackendProcess::destroy(
 
       Try<Nothing> rmdir = os::rmdir(rootfs);
       if (rmdir.isError()) {
-        return Failure(
-            "Failed to remove rootfs mount point '" + rootfs + "': " +
-            rmdir.error());
+        // NOTE: Due to the use of MNT_DETACH above, it's possible
+        // that `rmdir` will fail with EBUSY if some other mounts in
+        // other mount namespaces are still on this mount point on
+        // some old kernel (https://lwn.net/Articles/570338/). No need
+        // to return a hard failure here because the directory will be
+        // removed later and re-attempted on agent recovery.
+        //
+        // TODO(jieyu): Consider only ignore EBUSY error.
+        LOG(ERROR) << "Failed to remove rootfs mount point "
+                   << "'" << rootfs << "': " << rmdir.error();
       }
 
       // Clean up tempDir used for image layer links.

Reply via email to