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/02 04:48:42 UTC

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

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/b9d52a98
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b9d52a98
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b9d52a98

Branch: refs/heads/1.0.x
Commit: b9d52a98b4d412bf42d1e8a5de5b84fb9a227d10
Parents: 62c7c70
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 21:47:45 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/b9d52a98/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