You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/08/21 09:10:58 UTC

[mesos] 01/02: Changed operator API to notify subscribers on every status change.

This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit a2f826d5a641b8ae3e5742ffeab7166281e296f8
Author: Benno Evers <be...@mesosphere.com>
AuthorDate: Tue Aug 21 10:58:35 2018 +0200

    Changed operator API to notify subscribers on every status change.
    
    Prior to this change, the master would only send `TaskUpdated`
    messages to subscribers when the latest known task state on the
    agent changed.
    
    This implied that schedulers could not reliably wait for the status
    information corresponding to specific state updates, i.e.,
    `TASK_RUNNING`, since there is no guarantee that subscribers get
    notified during the time when this status update will be included in
    the status field.
    
    After this change, `TaskUpdated` messages are sent whenever the latest
    acknowledged state of the task changes.
    
    Review: https://reviews.apache.org/r/67575/
---
 include/mesos/master/master.proto    | 5 ++++-
 include/mesos/v1/master/master.proto | 5 ++++-
 src/master/master.cpp                | 7 +++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/mesos/master/master.proto b/include/mesos/master/master.proto
index 54f8412..ddb531f 100644
--- a/include/mesos/master/master.proto
+++ b/include/mesos/master/master.proto
@@ -602,7 +602,10 @@ message Event {
     // status update acknowledged by the scheduler.
     required TaskStatus status = 2;
 
-    // This is the latest state of the task according to the agent.
+    // This is the latest state of the task according to the agent,
+    // which can be more recent than `status` above but intermediate
+    // state changes may be skipped if they happen faster than the
+    // scheduler can acknowledge them.
     required TaskState state = 3;
   }
 
diff --git a/include/mesos/v1/master/master.proto b/include/mesos/v1/master/master.proto
index 12f019d..1367b48 100644
--- a/include/mesos/v1/master/master.proto
+++ b/include/mesos/v1/master/master.proto
@@ -598,7 +598,10 @@ message Event {
     // status update acknowledged by the scheduler.
     required TaskStatus status = 2;
 
-    // This is the latest state of the task according to the agent.
+    // This is the latest state of the task according to the agent,
+    // which can be more recent than `status` above but intermediate
+    // state changes may be skipped if they happen faster than the
+    // scheduler can acknowledge them.
     required TaskState state = 3;
   }
 
diff --git a/src/master/master.cpp b/src/master/master.cpp
index ad83be2..5825837 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -10826,10 +10826,6 @@ void Master::updateTask(Task* task, const StatusUpdate& update)
   // TODO(bmahler): Check that we're not transitioning from
   // TASK_UNREACHABLE to another state.
   if (!protobuf::isTerminalState(task->state())) {
-    if (status.state() != task->state()) {
-      sendSubscribersUpdate = true;
-    }
-
     if (task->state() != updateState && framework != nullptr) {
       // When we observe a transition away from a non-terminal state,
       // decrement the relevant metric.
@@ -10852,6 +10848,9 @@ void Master::updateTask(Task* task, const StatusUpdate& update)
   if (task->statuses_size() > 0 &&
       task->statuses(task->statuses_size() - 1).state() == status.state()) {
     task->mutable_statuses()->RemoveLast();
+  } else {
+    // Send a `TASK_UPDATED` event for every new task state.
+    sendSubscribersUpdate = true;
   }
   task->add_statuses()->CopyFrom(status);