Repository: mesos Updated Branches: refs/heads/master acf61580f -> 3f6d2ac4a
Added some defensive checks for persistent volume sharing check. This patch adds some defensive checks for detecting if a persistent volume is shared by multiple containers. It's currently not a bug because of a `contains` check above in the loop body and we set `info->resources` only after we update the volumes. But this is a bit fragile and should be avoided. See more details in MESOS-8356. Review: https://reviews.apache.org/r/65050/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3f6d2ac4 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3f6d2ac4 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3f6d2ac4 Branch: refs/heads/master Commit: 3f6d2ac4af5a74be27223a1917f8df43217e721a Parents: acf6158 Author: Jie Yu <[email protected]> Authored: Tue Jan 9 15:32:19 2018 -0800 Committer: Jie Yu <[email protected]> Committed: Tue Jan 9 15:32:19 2018 -0800 ---------------------------------------------------------------------- .../containerizer/mesos/isolators/filesystem/linux.cpp | 9 ++++++++- .../containerizer/mesos/isolators/filesystem/posix.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/3f6d2ac4/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp index 5200182..f1d377e 100644 --- a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp +++ b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp @@ -499,7 +499,14 @@ Future<Nothing> LinuxFilesystemIsolatorProcess::update( bool isVolumeInUse = false; - foreachvalue (const Owned<Info>& info, infos) { + foreachpair (const ContainerID& _containerId, + const Owned<Info>& info, + infos) { + // Skip self. + if (_containerId == containerId) { + continue; + } + if (info->resources.contains(resource)) { isVolumeInUse = true; break; http://git-wip-us.apache.org/repos/asf/mesos/blob/3f6d2ac4/src/slave/containerizer/mesos/isolators/filesystem/posix.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/isolators/filesystem/posix.cpp b/src/slave/containerizer/mesos/isolators/filesystem/posix.cpp index 6b9f4bb..df240bc 100644 --- a/src/slave/containerizer/mesos/isolators/filesystem/posix.cpp +++ b/src/slave/containerizer/mesos/isolators/filesystem/posix.cpp @@ -185,7 +185,14 @@ Future<Nothing> PosixFilesystemIsolatorProcess::update( bool isVolumeInUse = false; - foreachvalue (const Owned<Info>& info, infos) { + foreachpair (const ContainerID& _containerId, + const Owned<Info>& info, + infos) { + // Skip self. + if (_containerId == containerId) { + continue; + } + if (info->resources.contains(resource)) { isVolumeInUse = true; break;
