Added validation for missing ExecutorInfo::framework_id.

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


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

Branch: refs/heads/master
Commit: 8f4dd6377f6a71405551bcc1822afa2e73815fcb
Parents: e1befdc
Author: Benjamin Mahler <[email protected]>
Authored: Tue Sep 30 11:37:30 2014 -0700
Committer: Benjamin Mahler <[email protected]>
Committed: Wed Oct 8 11:45:11 2014 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8f4dd637/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 79588da..a1716f4 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1985,6 +1985,18 @@ struct ExecutorInfoChecker : TaskInfoVisitor
     }
 
     if (task.has_executor()) {
+      // The master currently expects ExecutorInfo.framework_id
+      // to be set even though it is an optional field.
+      // Currently, the scheduler driver ensures that the field
+      // is set. For schedulers not using the driver, we need to
+      // do the validation here.
+      // TODO(bmahler): Set this field in the master instead of
+      // depending on the scheduler driver do it.
+      if (!task.executor().has_framework_id()) {
+        return stringify(
+            "Task has invalid ExecutorInfo: missing field 'framework_id'");
+      }
+
       const ExecutorID& executorId = task.executor().executor_id();
       Option<ExecutorInfo> executorInfo = None();
 
@@ -2008,15 +2020,15 @@ struct ExecutorInfoChecker : TaskInfoVisitor
       }
 
       if (executorInfo.isSome() && !(task.executor() == executorInfo.get())) {
-          return "Task has invalid ExecutorInfo (existing ExecutorInfo"
-              " with same ExecutorID is not compatible).\n"
-              "------------------------------------------------------------\n"
-              "Existing ExecutorInfo:\n" +
-              stringify(executorInfo.get()) + "\n"
-              "------------------------------------------------------------\n"
-              "Task's ExecutorInfo:\n" +
-              stringify(task.executor()) + "\n"
-              "------------------------------------------------------------\n";
+        return "Task has invalid ExecutorInfo (existing ExecutorInfo"
+               " with same ExecutorID is not compatible).\n"
+               "------------------------------------------------------------\n"
+               "Existing ExecutorInfo:\n" +
+               stringify(executorInfo.get()) + "\n"
+               "------------------------------------------------------------\n"
+               "Task's ExecutorInfo:\n" +
+               stringify(task.executor()) + "\n"
+               
"------------------------------------------------------------\n";
       }
     }
 

Reply via email to