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:51 UTC

[2/2] 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/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