You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/08/01 22:52:50 UTC

[1/2] mesos git commit: Updated containerizer.cpp to look for duplicates in '--containerizer'.

Repository: mesos
Updated Branches:
  refs/heads/master 7830d5f94 -> 8dc71da12


Updated containerizer.cpp to look for duplicates in '--containerizer'.

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


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

Branch: refs/heads/master
Commit: 3043a693884ea7ac0efacd8fbf494710eacdef4c
Parents: 7830d5f
Author: Kevin Klues <kl...@gmail.com>
Authored: Mon Aug 1 15:52:40 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Aug 1 15:52:40 2016 -0700

----------------------------------------------------------------------
 src/slave/containerizer/containerizer.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3043a693/src/slave/containerizer/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/containerizer.cpp b/src/slave/containerizer/containerizer.cpp
index d66356d..f10a08a 100644
--- a/src/slave/containerizer/containerizer.cpp
+++ b/src/slave/containerizer/containerizer.cpp
@@ -211,6 +211,15 @@ Try<Containerizer*> Containerizer::create(
     return containerizer.get();
   }
 
+  // Get the set of containerizer types.
+  const vector<string> _types = strings::split(flags.containerizers, ",");
+  const set<string> containerizerTypes(_types.begin(), _types.end());
+
+  if (containerizerTypes.size() != _types.size()) {
+    return Error("Duplicate entries found in --containerizer flag"
+                 " '" + flags.containerizers + "'");
+  }
+
   // Optionally create the Nvidia components.
   Option<NvidiaComponents> nvidia;
 
@@ -247,7 +256,7 @@ Try<Containerizer*> Containerizer::create(
   // Create containerizer(s).
   vector<Containerizer*> containerizers;
 
-  foreach (const string& type, strings::split(flags.containerizers, ",")) {
+  foreach (const string& type, containerizerTypes) {
     if (type == "mesos") {
       Try<MesosContainerizer*> containerizer =
         MesosContainerizer::create(flags, local, fetcher, nvidia);


[2/2] mesos git commit: Added extra conditions for deciding when to create "NvidiaComponents".

Posted by ji...@apache.org.
Added extra conditions for deciding when to create "NvidiaComponents".

A recent addition to ensure that 'NvidiaVolume::create()' ran as root
broke all non-root tests on GPU machines.  The reason is that we
unconditionally create this volume so long as we detect
'nvml.isAvailable()', which will fail now that we are only allowed to
create this volume if we have root permissions.

We fix this by adding the proper conditions to determine when / if we
should create this volume based on some combination of --containerizer
and --isolation flags.

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


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

Branch: refs/heads/master
Commit: 8dc71da12c9b91edd2fa6c7b9a0a088b7dbb0ad3
Parents: 3043a69
Author: Kevin Klues <kl...@gmail.com>
Authored: Mon Aug 1 15:52:43 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Aug 1 15:52:43 2016 -0700

----------------------------------------------------------------------
 src/slave/containerizer/containerizer.cpp | 52 ++++++++++++++++++--------
 1 file changed, 36 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8dc71da1/src/slave/containerizer/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/containerizer.cpp b/src/slave/containerizer/containerizer.cpp
index f10a08a..ba3b3f6 100644
--- a/src/slave/containerizer/containerizer.cpp
+++ b/src/slave/containerizer/containerizer.cpp
@@ -225,28 +225,48 @@ Try<Containerizer*> Containerizer::create(
 
 #ifdef __linux__
   if (nvml::isAvailable()) {
-    Try<Resources> gpus = NvidiaGpuAllocator::resources(flags);
-
-    if (gpus.isError()) {
-      return Error("Failed call to NvidiaGpuAllocator::resources: " +
-                   gpus.error());
+    // If we are using the docker containerizer (either alone or in
+    // conjunction with the mesos containerizer), unconditionally
+    // create the Nvidia components and pass them through. If we are
+    // using the mesos containerizer alone, make sure we also have the
+    // `gpu/nvidia` isolator flag set before creating these components.
+    bool shouldCreate = false;
+
+    if (containerizerTypes.count("docker") > 0) {
+      shouldCreate = true;
+    } else if (containerizerTypes.count("mesos") > 0) {
+      const vector<string> _isolators = strings::tokenize(flags.isolation, ",");
+      const set<string> isolators(_isolators.begin(), _isolators.end());
+
+      if (isolators.count("gpu/nvidia") > 0) {
+        shouldCreate = true;
+      }
     }
 
-    Try<NvidiaGpuAllocator> allocator =
-      NvidiaGpuAllocator::create(flags, gpus.get());
+    if (shouldCreate) {
+      Try<Resources> gpus = NvidiaGpuAllocator::resources(flags);
 
-    if (allocator.isError()) {
-      return Error("Failed to NvidiaGpuAllocator::create: " +
-                   allocator.error());
-    }
+      if (gpus.isError()) {
+        return Error("Failed call to NvidiaGpuAllocator::resources: " +
+                     gpus.error());
+      }
 
-    Try<NvidiaVolume> volume = NvidiaVolume::create();
+      Try<NvidiaGpuAllocator> allocator =
+        NvidiaGpuAllocator::create(flags, gpus.get());
 
-    if (volume.isError()) {
-      return Error("Failed to NvidiaVolume::create: " + volume.error());
-    }
+      if (allocator.isError()) {
+        return Error("Failed to NvidiaGpuAllocator::create: " +
+                     allocator.error());
+      }
+
+      Try<NvidiaVolume> volume = NvidiaVolume::create();
 
-    nvidia = NvidiaComponents(allocator.get(), volume.get());
+      if (volume.isError()) {
+        return Error("Failed to NvidiaVolume::create: " + volume.error());
+      }
+
+      nvidia = NvidiaComponents(allocator.get(), volume.get());
+    }
   }
 #endif