Repository: mesos Updated Branches: refs/heads/master 4b12df29c -> 4f3448cc5
Only unmount sandbox if the mount exists in LinuxFilesystemIsolator. Review: https://reviews.apache.org/r/38444 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4f3448cc Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4f3448cc Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4f3448cc Branch: refs/heads/master Commit: 4f3448cc5e300f891feb395d3a2c0e2c05add2c5 Parents: e9d3007 Author: Jie Yu <[email protected]> Authored: Wed Sep 16 17:27:11 2015 -0700 Committer: Jie Yu <[email protected]> Committed: Wed Sep 16 21:37:28 2015 -0700 ---------------------------------------------------------------------- .../isolators/filesystem/linux.cpp | 32 +++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/4f3448cc/src/slave/containerizer/isolators/filesystem/linux.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/isolators/filesystem/linux.cpp b/src/slave/containerizer/isolators/filesystem/linux.cpp index d8a0e07..b674634 100644 --- a/src/slave/containerizer/isolators/filesystem/linux.cpp +++ b/src/slave/containerizer/isolators/filesystem/linux.cpp @@ -721,11 +721,15 @@ Future<Nothing> LinuxFilesystemIsolatorProcess::cleanup( return Failure("Failed to get mount table: " + table.error()); } + bool sandboxMountExists = false; + foreach (const fs::MountInfoTable::Entry& entry, table.get().entries) { // NOTE: All persistent volumes are mounted at targets under the - // container's work directory. - if (entry.target != sandbox && - strings::startsWith(entry.target, sandbox)) { + // container's work directory. We unmount all the persistent + // volumes before unmounting the sandbox/work directory mount. + if (entry.target == sandbox) { + sandboxMountExists = true; + } else if (strings::startsWith(entry.target, sandbox)) { LOG(INFO) << "Unmounting volume '" << entry.target << "' for container " << containerId; @@ -738,15 +742,21 @@ Future<Nothing> LinuxFilesystemIsolatorProcess::cleanup( } } - // Cleanup the container's work directory mount. - LOG(INFO) << "Unmounting sandbox/work directory '" << sandbox - << "' for container " << containerId; + if (!sandboxMountExists) { + // This could happen if the container is not launched by this + // isolator (e.g., slaves prior to 0.25.0). + LOG(WARNING) << "Ignoring unmounting sandbox/work directory" + << " for container " << containerId; + } else { + LOG(INFO) << "Unmounting sandbox/work directory '" << sandbox + << "' for container " << containerId; - Try<Nothing> unmount = fs::unmount(sandbox); - if (unmount.isError()) { - return Failure( - "Failed to unmount sandbox/work directory '" + sandbox + - "': " + unmount.error()); + Try<Nothing> unmount = fs::unmount(sandbox); + if (unmount.isError()) { + return Failure( + "Failed to unmount sandbox/work directory '" + sandbox + + "': " + unmount.error()); + } } // Destroy the provisioned root filesystems.
