Repository: mesos Updated Branches: refs/heads/master b9982ba8d -> 5ff1b45d7
Improve logging of clone flags for linux_launcher Review: https://reviews.apache.org/r/33746 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5ff1b45d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5ff1b45d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5ff1b45d Branch: refs/heads/master Commit: 5ff1b45d70dec79605a841e8498774a1b03e3103 Parents: b9982ba Author: Ian Downes <[email protected]> Authored: Thu Apr 30 22:18:52 2015 -0700 Committer: Ian Downes <[email protected]> Committed: Fri May 22 11:00:51 2015 -0700 ---------------------------------------------------------------------- src/linux/ns.hpp | 28 ++++++++++++++++++++++++- src/slave/containerizer/linux_launcher.cpp | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/5ff1b45d/src/linux/ns.hpp ---------------------------------------------------------------------- diff --git a/src/linux/ns.hpp b/src/linux/ns.hpp index 87ff82c..b695f3a 100644 --- a/src/linux/ns.hpp +++ b/src/linux/ns.hpp @@ -27,6 +27,7 @@ #include <set> #include <string> +#include <vector> #include <stout/error.hpp> #include <stout/hashmap.hpp> @@ -35,6 +36,7 @@ #include <stout/path.hpp> #include <stout/proc.hpp> #include <stout/stringify.hpp> +#include <stout/strings.hpp> #include <stout/try.hpp> #include <stout/os/exists.hpp> @@ -292,13 +294,37 @@ inline process::Future<Nothing> destroy(ino_t inode) } // Wait for all the signalled processes to terminate. The pid - // namespace wil then be empty and will be released by the kernel + // namespace will then be empty and will be released by the kernel // (unless there are additional references). return process::collect(futures) .then(lambda::bind(&internal::_nothing)); } } // namespace pid { + + +// Returns the namespace flags in the string form of bitwise-ORing the +// flags, e.g., CLONE_NEWNS | CLONE_NEWNET. +inline std::string stringify(int flags) +{ + hashmap<unsigned int, std::string> names = { + {CLONE_NEWIPC, "CLONE_NEWIPC"}, + {CLONE_NEWNET, "CLONE_NEWNET"}, + {CLONE_NEWNS, "CLONE_NEWNS"}, + {CLONE_NEWPID, "CLONE_NEWPID"}, + {CLONE_NEWUTS, "CLONE_NEWUTS"} + }; + + std::vector<std::string> namespaces; + foreachpair (unsigned int flag, const std::string& name, names) { + if (flags & flag) { + namespaces.push_back(name); + } + } + + return strings::join(" | ", namespaces); +} + } // namespace ns { #endif // __LINUX_NS_HPP__ http://git-wip-us.apache.org/repos/asf/mesos/blob/5ff1b45d/src/slave/containerizer/linux_launcher.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/linux_launcher.cpp b/src/slave/containerizer/linux_launcher.cpp index b9e22e3..8eae258 100644 --- a/src/slave/containerizer/linux_launcher.cpp +++ b/src/slave/containerizer/linux_launcher.cpp @@ -209,7 +209,8 @@ static pid_t clone(const lambda::function<int()>& func, int namespaces) // - 8 MiB appears to be the default for "ulimit -s" on OSX and Linux. static unsigned long long stack[(8*1024*1024)/sizeof(unsigned long long)]; - LOG(INFO) << "Cloning child process with flags = " << namespaces; + LOG(INFO) << "Cloning child process with flags = " + << ns::stringify(namespaces); return ::clone( childMain,
