You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/01/24 21:36:15 UTC

git commit: Fixed slave to properly do memory isolation when executor resources are not specified.

Updated Branches:
  refs/heads/master 1c7ab021f -> 45a773922


Fixed slave to properly do memory isolation when executor resources
are not specified.

From: Vinod Kone <vi...@gmail.com>
Review: https://reviews.apache.org/r/17295


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

Branch: refs/heads/master
Commit: 45a773922c07d5d63230efd0abd4fb239b899edd
Parents: 1c7ab02
Author: Vinod Kone <vi...@twitter.com>
Authored: Fri Jan 24 12:35:56 2014 -0800
Committer: Vinod Kone <vi...@twitter.com>
Committed: Fri Jan 24 12:35:56 2014 -0800

----------------------------------------------------------------------
 src/slave/cgroups_isolator.cpp |  7 +++++++
 src/slave/slave.cpp            | 12 +++++++++---
 src/slave/slave.hpp            |  4 +++-
 3 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/45a77392/src/slave/cgroups_isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/cgroups_isolator.cpp b/src/slave/cgroups_isolator.cpp
index 80155a3..5298f20 100644
--- a/src/slave/cgroups_isolator.cpp
+++ b/src/slave/cgroups_isolator.cpp
@@ -703,6 +703,13 @@ void CgroupsIsolator::resourcesChanged(
     return;
   }
 
+  if (info->resources == resources) {
+    // This could happen when 'resourcesChanged()' is called after
+    // launching the first task since the executor includes the
+    // resources for the first task.
+    return;
+  }
+
   info->resources = resources;
 
   LOG(INFO) << "Changing cgroup controls for executor " << executorId

http://git-wip-us.apache.org/repos/asf/mesos/blob/45a77392/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index aeecca0..2d21e16 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -913,7 +913,7 @@ void Slave::_runTask(
   Executor* executor = framework->getExecutor(executorId);
 
   if (executor == NULL) {
-    executor = framework->launchExecutor(executorInfo);
+    executor = framework->launchExecutor(executorInfo, task);
   }
 
   CHECK_NOTNULL(executor);
@@ -2907,7 +2907,9 @@ Framework::~Framework()
 
 
 // Create and launch an executor.
-Executor* Framework::launchExecutor(const ExecutorInfo& executorInfo)
+Executor* Framework::launchExecutor(
+    const ExecutorInfo& executorInfo,
+    const TaskInfo& taskInfo)
 {
   // We create a UUID for the new executor. The UUID uniquely
   // identifies this new instance of the executor across executors
@@ -2939,6 +2941,10 @@ Executor* Framework::launchExecutor(const ExecutorInfo& executorInfo)
                  executor->directory));
 
   // Tell the isolator to launch the executor.
+  // NOTE: We include the task's resources when launching the
+  // executor so that the isolator has non-zero resources to
+  // work with when the executor has no resources. This should
+  // be revisited after MESOS-600.
   dispatch(slave->isolator,
            &Isolator::launchExecutor,
            slave->info.id(),
@@ -2947,7 +2953,7 @@ Executor* Framework::launchExecutor(const ExecutorInfo& executorInfo)
            executor->info,
            executor->uuid,
            executor->directory,
-           executor->resources);
+           executor->resources + taskInfo.resources());
 
   // Make sure the executor registers within the given timeout.
   delay(slave->flags.executor_registration_timeout,

http://git-wip-us.apache.org/repos/asf/mesos/blob/45a77392/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index b8acc18..891c874 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -448,7 +448,9 @@ struct Framework
 
   ~Framework();
 
-  Executor* launchExecutor(const ExecutorInfo& executorInfo);
+  Executor* launchExecutor(
+      const ExecutorInfo& executorInfo,
+      const TaskInfo& taskInfo);
   void destroyExecutor(const ExecutorID& executorId);
   Executor* getExecutor(const ExecutorID& executorId);
   Executor* getExecutor(const TaskID& taskId);