You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/09/24 06:18:35 UTC

[4/4] mesos git commit: Added recovery warnings for LinuxLauncher on Systemd.

Added recovery warnings for LinuxLauncher on Systemd.

Review: https://reviews.apache.org/r/38637


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/69393f77
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/69393f77
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/69393f77

Branch: refs/heads/master
Commit: 69393f77d0c1fe7b93cdac821164d65e153b44ee
Parents: 3a088cc
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Tue Sep 22 13:08:51 2015 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Wed Sep 23 20:59:24 2015 -0700

----------------------------------------------------------------------
 src/slave/containerizer/linux_launcher.cpp | 32 +++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/69393f77/src/slave/containerizer/linux_launcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/linux_launcher.cpp b/src/slave/containerizer/linux_launcher.cpp
index 2b33d2d..2e0ae70 100644
--- a/src/slave/containerizer/linux_launcher.cpp
+++ b/src/slave/containerizer/linux_launcher.cpp
@@ -183,6 +183,22 @@ Future<hashset<ContainerID>> LinuxLauncher::recover(
 {
   hashset<string> recovered;
 
+  // On systemd environments, capture the pids under the
+  // `SYSTEMD_MESOS_EXECUTORS_SLICE` for validation during recovery.
+  Result<std::set<pid_t>> mesosExecutorSlicePids = None();
+  if (systemdHierarchy.isSome()) {
+    mesosExecutorSlicePids =
+      cgroups::processes(systemdHierarchy.get(), SYSTEMD_MESOS_EXECUTORS_SLICE);
+
+    // If we error out trying to read the pids from the
+    // `SYSTEMD_MESOS_EXECUTORS_SLICE` we fail. This is a programmer error as we
+    // did not set up the slice correctly.
+    if (mesosExecutorSlicePids.isError()) {
+      return Failure("Failed to read pids from systemd `" +
+                     stringify(SYSTEMD_MESOS_EXECUTORS_SLICE) + "`");
+    }
+  }
+
   foreach (const ContainerState& state, states) {
     const ContainerID& containerId = state.container_id();
     pid_t pid = state.pid();
@@ -217,6 +233,22 @@ Future<hashset<ContainerID>> LinuxLauncher::recover(
       continue;
     }
 
+    // If we are on a systemd environment, check that the pid is still in the
+    // `SYSTEMD_MESOS_EXECUTORS_SLICE`. If it is not, warn the operator that
+    // resource isolation may be invalidated.
+    // TODO(jmlvanre): Add a flag that enforces this matching (i.e. exits if a
+    // pid was found in the freezer but not in the
+    // `SYSTEMD_MESOS_EXECUTORS_SLICE`. We need to flag to support the upgrade
+    // path.
+    if (systemdHierarchy.isSome() && mesosExecutorSlicePids.isSome()) {
+      if (mesosExecutorSlicePids.get().count(pid) <= 0) {
+        LOG(WARNING)
+          << "Couldn't find pid `" << pid << "` in `"
+          << SYSTEMD_MESOS_EXECUTORS_SLICE << "`. This can lead to lack of"
+          << " proper resource isolation";
+      }
+    }
+
     recovered.insert(cgroup(containerId));
   }