mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nniel...@apache.org
Subject mesos git commit: Updated slave task label decorator hook to pass in ExecutorInfo.
Date Tue, 11 Aug 2015 16:05:45 GMT
Repository: mesos
Updated Branches:
  refs/heads/master e47648a67 -> 7ac3258e5


Updated slave task label decorator hook to pass in ExecutorInfo.

If the task being launched has a command executor, there is no way for
the hook to determine the executor-id for that task. This update calls
the hook _after_ the ExecutorInfo has been created and thus is able to
pass in ExecutorInfo to the label decorator.

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


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

Branch: refs/heads/master
Commit: 7ac3258e5e8ee6686826de5e1f692b86dd29af0c
Parents: e47648a
Author: Kapil Arya <kapil@mesosphere.io>
Authored: Tue Aug 11 08:44:15 2015 -0700
Committer: Niklas Q. Nielsen <nik@qni.dk>
Committed: Tue Aug 11 08:44:25 2015 -0700

----------------------------------------------------------------------
 include/mesos/hook.hpp            |  1 +
 src/examples/test_hook_module.cpp |  1 +
 src/hook/manager.cpp              |  5 +++--
 src/hook/manager.hpp              |  1 +
 src/slave/slave.cpp               | 12 ++++++------
 5 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7ac3258e/include/mesos/hook.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/hook.hpp b/include/mesos/hook.hpp
index bb5a635..6c3861b 100644
--- a/include/mesos/hook.hpp
+++ b/include/mesos/hook.hpp
@@ -51,6 +51,7 @@ public:
   // labels overwrite the existing labels on the task info.
   virtual Result<Labels> slaveRunTaskLabelDecorator(
       const TaskInfo& taskInfo,
+      const ExecutorInfo& executorInfo,
       const FrameworkInfo& frameworkInfo,
       const SlaveInfo& slaveInfo)
   {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7ac3258e/src/examples/test_hook_module.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_hook_module.cpp b/src/examples/test_hook_module.cpp
index c664b56..2f0a1a0 100644
--- a/src/examples/test_hook_module.cpp
+++ b/src/examples/test_hook_module.cpp
@@ -86,6 +86,7 @@ public:
   // interference.
   virtual Result<Labels> slaveRunTaskLabelDecorator(
       const TaskInfo& taskInfo,
+      const ExecutorInfo& executorInfo,
       const FrameworkInfo& frameworkInfo,
       const SlaveInfo& slaveInfo)
   {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7ac3258e/src/hook/manager.cpp
----------------------------------------------------------------------
diff --git a/src/hook/manager.cpp b/src/hook/manager.cpp
index 11e6b0a..0b693d2 100644
--- a/src/hook/manager.cpp
+++ b/src/hook/manager.cpp
@@ -134,6 +134,7 @@ Labels HookManager::masterLaunchTaskLabelDecorator(
 
 Labels HookManager::slaveRunTaskLabelDecorator(
     const TaskInfo& taskInfo,
+    const ExecutorInfo& executorInfo,
     const FrameworkInfo& frameworkInfo,
     const SlaveInfo& slaveInfo)
 {
@@ -141,8 +142,8 @@ Labels HookManager::slaveRunTaskLabelDecorator(
     TaskInfo taskInfo_ = taskInfo;
 
     foreachpair (const string& name, Hook* hook, availableHooks) {
-      const Result<Labels> result =
-        hook->slaveRunTaskLabelDecorator(taskInfo_, frameworkInfo, slaveInfo);
+      const Result<Labels> result = hook->slaveRunTaskLabelDecorator(
+          taskInfo_, executorInfo, frameworkInfo, slaveInfo);
 
       // NOTE: If the hook returns None(), the task labels won't be
       // changed.

http://git-wip-us.apache.org/repos/asf/mesos/blob/7ac3258e/src/hook/manager.hpp
----------------------------------------------------------------------
diff --git a/src/hook/manager.hpp b/src/hook/manager.hpp
index 8153ce4..df32484 100644
--- a/src/hook/manager.hpp
+++ b/src/hook/manager.hpp
@@ -47,6 +47,7 @@ public:
 
   static Labels slaveRunTaskLabelDecorator(
       const TaskInfo& taskInfo,
+      const ExecutorInfo& executorInfo,
       const FrameworkInfo& frameworkInfo,
       const SlaveInfo& slaveInfo);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/7ac3258e/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 6adb488..2a99abc 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -1270,12 +1270,6 @@ void Slave::runTask(
     return;
   }
 
-  if (HookManager::hooksAvailable()) {
-    // Set task labels from run task label decorator.
-    task.mutable_labels()->CopyFrom(
-        HookManager::slaveRunTaskLabelDecorator(task, frameworkInfo, info));
-  }
-
   Future<bool> unschedule = true;
 
   // If we are about to create a new framework, unschedule the work
@@ -1323,6 +1317,12 @@ void Slave::runTask(
   const ExecutorInfo executorInfo = getExecutorInfo(frameworkId, task);
   const ExecutorID& executorId = executorInfo.executor_id();
 
+  if (HookManager::hooksAvailable()) {
+    // Set task labels from run task label decorator.
+    task.mutable_labels()->CopyFrom(HookManager::slaveRunTaskLabelDecorator(
+        task, executorInfo, frameworkInfo, info));
+  }
+
   // We add the task to 'pending' to ensure the framework is not
   // removed and the framework and top level executor directories
   // are not scheduled for deletion before '_runTask()' is called.


Mime
View raw message