Updated code and comments in Master::updateTask() that deals with
0.21.0 slaves.

The only functional change here is that updateTask() doesn't check for
uuid being set to empty string.

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


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

Branch: refs/heads/master
Commit: 6aa7004c153c8106589da70c17a35b7012a64711
Parents: c8277ef
Author: Vinod Kone <[email protected]>
Authored: Fri Nov 6 09:29:35 2015 -0800
Committer: Vinod Kone <[email protected]>
Committed: Fri Nov 6 10:09:59 2015 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6aa7004c/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index bad38ff..70e55a5 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6014,7 +6014,7 @@ void Master::updateTask(Task* task, const StatusUpdate& 
update)
     return;
   }
 
-  // Get the latest state.
+  // Updates from the slave have 'latest_state' set.
   Option<TaskState> latestState;
   if (update.has_latest_state()) {
     latestState = update.latest_state();
@@ -6024,14 +6024,11 @@ void Master::updateTask(Task* task, const StatusUpdate& 
update)
   // transitioned to terminal state. Also set the latest state.
   bool terminated;
   if (latestState.isSome()) {
-    // This update must be from >= 0.21.0 slave.
     terminated = !protobuf::isTerminalState(task->state()) &&
                  protobuf::isTerminalState(latestState.get());
 
     task->set_state(latestState.get());
   } else {
-    // This update must be from a pre 0.21.0 slave or generated by the
-    // master.
     terminated = !protobuf::isTerminalState(task->state()) &&
                  protobuf::isTerminalState(status.state());
 
@@ -6041,7 +6038,7 @@ void Master::updateTask(Task* task, const StatusUpdate& 
update)
   // Set the status update state and uuid for the task. Note that
   // master-generated updates are terminal and do not have a uuid
   // (in which case the master also calls removeTask()).
-  if (update.has_uuid() && update.uuid() != "") {
+  if (update.has_uuid()) {
     task->set_status_update_state(status.state());
     task->set_status_update_uuid(update.uuid());
   }
@@ -6061,12 +6058,10 @@ void Master::updateTask(Task* task, const StatusUpdate& 
update)
   // MESOS-1746.
   task->mutable_statuses(task->statuses_size() - 1)->clear_data();
 
-  LOG(INFO) << "Updating the latest state of task " << task->task_id()
+  LOG(INFO) << "Updating the state of task " << task->task_id()
             << " of framework " << task->framework_id()
-            << " to " << task->state()
-            << (task->state() != status.state()
-                ? " (status update state: " + stringify(status.state()) + ")"
-                : "");
+            << " (latest state: " << task->state()
+            << ", status update state: " << status.state() << ")";
 
   // Once the task becomes terminal, we recover the resources.
   if (terminated) {

Reply via email to