You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/05/23 21:36:54 UTC

[10/10] mesos git commit: Windows: Fixed pipe inheritance in Mesos containerizer.

Windows: Fixed pipe inheritance in Mesos containerizer.

The Mesos containerizer needs an inheritable pipe that is not used for
stdio of the child process. It is used for signaling when the child
process should start running, so the pipe needs to be inheritable and
not overlapped.

Note this is going to change when handle white-listing is implemented,
as this control pipe will need to be passed explicitly, instead of the
current design where it is passed implicitly through an environment
variable.

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


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

Branch: refs/heads/master
Commit: 028bb605afb519a9474b477f21a03ddaafd5eb42
Parents: 07f5c00
Author: Akash Gupta <ak...@hotmail.com>
Authored: Wed May 23 14:02:49 2018 -0700
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Wed May 23 14:07:47 2018 -0700

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 23 ++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/028bb605/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index eac1d16..51edb58 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -44,6 +44,10 @@
 #include <stout/strings.hpp>
 #include <stout/unreachable.hpp>
 
+#ifdef __WINDOWS__
+#include <stout/internal/windows/inherit.hpp>
+#endif // __WINDOWS__
+
 #include <stout/os/wait.hpp>
 
 #include "common/protobuf_utils.hpp"
@@ -1857,12 +1861,27 @@ Future<Containerizer::LaunchResult> MesosContainerizerProcess::_launch(
 
   // Use a pipe to block the child until it's been isolated.
   // The `pipes` array is captured later in a lambda.
-  Try<std::array<int_fd, 2>> pipes_ = os::pipe();
-
+  //
   // TODO(jmlvanre): consider returning failure if `pipe` gives an
   // error. Currently we preserve the previous logic.
+#ifdef __WINDOWS__
+  // On Windows, we have to make the pipes inheritable and not overlapped, since
+  // that's what the mesos container launcher assumes.
+  Try<std::array<int_fd, 2>> pipes_ = os::pipe(false, false);
   CHECK_SOME(pipes_);
 
+  foreach (const int_fd& fd, pipes_.get()) {
+    Try<Nothing> result = ::internal::windows::set_inherit(fd, true);
+    if (result.isError()) {
+      return Failure(
+          "Could not set pipe inheritance for launcher: " + result.error());
+    }
+  }
+#else
+  Try<std::array<int_fd, 2>> pipes_ = os::pipe();
+  CHECK_SOME(pipes_);
+#endif // __WINDOWS__
+
   const std::array<int_fd, 2>& pipes = pipes_.get();
 
   // Prepare the flags to pass to the launch process.