This is an automated email from the ASF dual-hosted git repository. gilbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 33710c0af5662c53ee8b309b4474cfa005eac2c6 Author: Jie Yu <[email protected]> AuthorDate: Fri Aug 31 22:29:36 2018 -0700 Made overlay 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/68594/ --- .../mesos/provisioner/backends/overlay.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/slave/containerizer/mesos/provisioner/backends/overlay.cpp b/src/slave/containerizer/mesos/provisioner/backends/overlay.cpp index e32b991..b12b5b2 100644 --- a/src/slave/containerizer/mesos/provisioner/backends/overlay.cpp +++ b/src/slave/containerizer/mesos/provisioner/backends/overlay.cpp @@ -252,8 +252,11 @@ Future<bool> OverlayBackendProcess::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 overlay-mounted rootfs '" + rootfs + "': " + @@ -262,9 +265,16 @@ Future<bool> OverlayBackendProcess::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.
