Repository: mesos
Updated Branches:
  refs/heads/master f2bcfc335 -> 7dca9dbbb


Fixed command executor path check

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


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

Branch: refs/heads/master
Commit: 7dca9dbbb6b6589cd91f77d908b81655b7bf8b31
Parents: f2bcfc3
Author: Timothy Chen <[email protected]>
Authored: Wed Sep 10 12:59:20 2014 -0700
Committer: Adam B <[email protected]>
Committed: Wed Sep 10 12:59:53 2014 -0700

----------------------------------------------------------------------
 src/slave/slave.cpp | 27 +++++++++++++++++++--------
 src/slave/slave.hpp |  7 +++++--
 2 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7dca9dbb/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index f1df9d1..1b3dc73 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -923,7 +923,7 @@ void Slave::doReliableRegistration(const Duration& duration)
 
         // Do not re-register with Command Executors because the
         // master doesn't store them; they are generated by the slave.
-        if (executor->commandExecutor) {
+        if (executor->isCommandExecutor()) {
           // NOTE: We have to unset the executor id here for the task
           // because the master uses the absence of task.executor_id()
           // to detect command executors.
@@ -2670,7 +2670,7 @@ void Slave::executorTerminated(
           if (!protobuf::isTerminalState(task->state())) {
             mesos::TaskState taskState;
             if ((termination.isReady() && termination.get().killed()) ||
-                 executor->commandExecutor) {
+                executor->isCommandExecutor()) {
               taskState = TASK_FAILED;
             } else {
               taskState = TASK_LOST;
@@ -2693,7 +2693,7 @@ void Slave::executorTerminated(
         foreach (const TaskInfo& task, executor->queuedTasks.values()) {
           mesos::TaskState taskState;
           if ((termination.isReady() && termination.get().killed()) ||
-               executor->commandExecutor) {
+              executor->isCommandExecutor()) {
             taskState = TASK_FAILED;
           } else {
             taskState = TASK_LOST;
@@ -2713,7 +2713,7 @@ void Slave::executorTerminated(
       // Only send ExitedExecutorMessage if it is not a Command
       // Executor because the master doesn't store them; they are
       // generated by the slave.
-      if (!executor->commandExecutor) {
+      if (!executor->isCommandExecutor()) {
         ExitedExecutorMessage message;
         message.mutable_slave_id()->MergeFrom(info.id());
         message.mutable_framework_id()->MergeFrom(frameworkId);
@@ -3642,7 +3642,7 @@ Executor* Framework::launchExecutor(
 
   // Launch the container.
   Future<bool> launch;
-  if (!executor->commandExecutor) {
+  if (!executor->isCommandExecutor()) {
     // If the executor is _not_ a command executor, this means that
     // the task will include the executor to run. The actual task to
     // run will be enqueued and subsequently handled by the executor
@@ -3869,15 +3869,20 @@ Executor::Executor(
     containerId(_containerId),
     directory(_directory),
     checkpoint(_checkpoint),
-    commandExecutor(strings::contains(
-        info.command().value(),
-        path::join(slave->flags.launcher_dir, "mesos-executor"))),
     pid(UPID()),
     resources(_info.resources()),
     completedTasks(MAX_COMPLETED_TASKS_PER_EXECUTOR)
 {
   CHECK_NOTNULL(slave);
 
+  Result<string> executorPath =
+    os::realpath(path::join(slave->flags.launcher_dir, "mesos-executor"));
+
+  if (executorPath.isSome()) {
+    commandExecutor =
+      strings::contains(info.command().value(), executorPath.get());
+  }
+
   if (checkpoint && slave->state != slave->RECOVERING) {
     // Checkpoint the executor info.
     const string& path = paths::getExecutorInfoPath(
@@ -4061,6 +4066,12 @@ bool Executor::incompleteTasks()
 }
 
 
+bool Executor::isCommandExecutor()
+{
+  return commandExecutor;
+}
+
+
 std::ostream& operator << (std::ostream& stream, Slave::State state)
 {
   switch (state) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7dca9dbb/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index a418536..4f3df5c 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -499,6 +499,9 @@ struct Executor
   // Returns true if there are any queued/launched/terminated tasks.
   bool incompleteTasks();
 
+  // Returns true if this is a command executor.
+  bool isCommandExecutor();
+
   enum State {
     REGISTERING,  // Executor is launched but not (re-)registered yet.
     RUNNING,      // Executor has (re-)registered.
@@ -522,8 +525,6 @@ struct Executor
 
   const bool checkpoint;
 
-  const bool commandExecutor;
-
   process::UPID pid;
 
   // Currently consumed resources.
@@ -549,6 +550,8 @@ struct Executor
 private:
   Executor(const Executor&);              // No copying.
   Executor& operator = (const Executor&); // No assigning.
+
+  bool commandExecutor;
 };
 
 

Reply via email to