Fixed an issue for the I/O switchboard process lifetime.

We expect the I/O switchboard process to last across agent restarts
(similar to log rotate process or executor processes). Therefore, we
should put it into 'mesos_executor.slice' like others.

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


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

Branch: refs/heads/master
Commit: 05a2909508df56253372b4fe36330339b5de00b1
Parents: 2ece53c
Author: Jie Yu <yujie....@gmail.com>
Authored: Thu Oct 5 20:52:38 2017 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Fri Feb 9 17:04:04 2018 -0800

----------------------------------------------------------------------
 src/slave/containerizer/mesos/io/switchboard.cpp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/05a29095/src/slave/containerizer/mesos/io/switchboard.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp 
b/src/slave/containerizer/mesos/io/switchboard.cpp
index aeb0b3e..ba77404 100644
--- a/src/slave/containerizer/mesos/io/switchboard.cpp
+++ b/src/slave/containerizer/mesos/io/switchboard.cpp
@@ -64,6 +64,10 @@
 #include "common/recordio.hpp"
 #include "common/status_utils.hpp"
 
+#ifdef __linux__
+#include "linux/systemd.hpp"
+#endif // __linux__
+
 #include "slave/flags.hpp"
 #include "slave/state.hpp"
 
@@ -557,6 +561,18 @@ Future<Option<ContainerLaunchInfo>> 
IOSwitchboard::_prepare(
   VLOG(1) << "Launching '" << IOSwitchboardServer::NAME << "' with flags '"
           << switchboardFlags << "' for container " << containerId;
 
+  // If we are on systemd, then extend the life of the process as we
+  // do with the executor. Any grandchildren's lives will also be
+  // extended.
+  vector<Subprocess::ParentHook> parentHooks;
+
+#ifdef __linux__
+  if (systemd::enabled()) {
+    parentHooks.emplace_back(Subprocess::ParentHook(
+        &systemd::mesos::extendLifetime));
+  }
+#endif // __linux__
+
   // Launch the io switchboard server process.
   // We `dup()` the `stdout` and `stderr` passed to us by the
   // container logger over the `stdout` and `stderr` of the io
@@ -572,7 +588,7 @@ Future<Option<ContainerLaunchInfo>> IOSwitchboard::_prepare(
       &switchboardFlags,
       environment,
       None(),
-      {},
+      parentHooks,
       {Subprocess::ChildHook::SETSID(),
        Subprocess::ChildHook::UNSET_CLOEXEC(stdinToFd),
        Subprocess::ChildHook::UNSET_CLOEXEC(stdoutFromFd),

Reply via email to