You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2019/07/18 00:07:36 UTC

[mesos] branch master updated (af54474 -> b96268c)

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

chhsiao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from af54474  Windows: Fixed exclusion of GID and Docker spec headers.
     new 586dba8  Sequentialized all events to master's `/api/v1` subscribers.
     new a17a536  Notifies master `/api/v1` subscribers about recovered frameworks.
     new b96268c  Added MESOS-9785 to the 1.8.2 CHANGELOG.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGELOG                     | 10 ++++++++++
 src/common/protobuf_utils.cpp |  4 ----
 src/master/master.cpp         | 22 ++++++++++++++++++++--
 src/master/master.hpp         | 11 +++++++++++
 src/tests/api_tests.cpp       | 40 ++++++++++++++++++++++++++++++----------
 5 files changed, 71 insertions(+), 16 deletions(-)


[mesos] 03/03: Added MESOS-9785 to the 1.8.2 CHANGELOG.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit b96268cdcfd765152ef95ba64ca3d5260c4e384c
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Wed May 22 14:44:28 2019 -0700

    Added MESOS-9785 to the 1.8.2 CHANGELOG.
---
 CHANGELOG | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 164465a..7b464f1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,15 @@ Additional API Changes:
     NOTE: This new overload is only available when libprocess is compiled
     with `--enable-ssl`.
 
+
+Release Notes - Mesos - Version 1.8.2 (WIP)
+-------------------------------------------
+* This is a bug fix release.
+
+** Bug
+  * [MESOS-9785] - Frameworks recovered from reregistered agents are not reported to master `/api/v1` subscribers.
+
+
 Release Notes - Mesos - Version 1.8.1 (WIP)
 -------------------------------------------
 * This is a bug fix release.
@@ -57,6 +66,7 @@ Release Notes - Mesos - Version 1.8.1 (WIP)
 ** Improvement
   * [MESOS-9759] - Log required quota headroom and available quota headroom in the allocator.
 
+
 Release Notes - Mesos - Version 1.8.0
 -------------------------------------
 This release contains the following highlights:


[mesos] 02/03: Notifies master `/api/v1` subscribers about recovered frameworks.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit a17a536611ca38783bfdf86630664f86562ea98e
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Wed May 15 21:54:20 2019 -0700

    Notifies master `/api/v1` subscribers about recovered frameworks.
    
    If one subscribes to master's `/api/v1` endpoint after a master failover
    but before an agent reregistration, frameworks recovered through the
    agent registration should be notified to the subscriber, otherwise
    recovered tasks will have framework IDs referring to frameworks unknown
    to the subscriber.
    
    Review: https://reviews.apache.org/r/70651
---
 src/common/protobuf_utils.cpp |  4 ----
 src/master/master.cpp         |  7 +++++++
 src/tests/api_tests.cpp       | 40 ++++++++++++++++++++++++++++++----------
 3 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index fc67c38..7778e7f 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -1438,10 +1438,6 @@ mesos::master::Event createTaskAdded(const Task& task)
 mesos::master::Event createFrameworkAdded(
     const mesos::internal::master::Framework& _framework)
 {
-  CHECK(_framework.active());
-  CHECK(_framework.connected());
-  CHECK(!_framework.recovered());
-
   mesos::master::Event event;
   event.set_type(mesos::master::Event::FRAMEWORK_ADDED);
 
diff --git a/src/master/master.cpp b/src/master/master.cpp
index ace05b2..fbde112 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -10893,6 +10893,13 @@ void Master::recoverFramework(
 
   Framework* framework = new Framework(this, flags, info);
 
+  // Send a `FRAMEWORK_ADDED` event to subscribers before adding recovered tasks
+  // so the framework ID referred by any succeeding `TASK_ADDED` event will be
+  // known to subscribers.
+  if (!subscribers.subscribed.empty()) {
+    subscribers.send(protobuf::master::event::createFrameworkAdded(*framework));
+  }
+
   // Add active operations, tasks, and executors to the framework.
   foreachvalue (Slave* slave, slaves.registered) {
     if (slave->tasks.contains(framework->id())) {
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 561ff20..3479ed3 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -2630,8 +2630,9 @@ TEST_P(MasterAPITest, SubscribersReceiveHealthUpdates)
 
 
 // This test verifies that subscribing to the 'api/v1' endpoint between
-// a master failover and an agent re-registration won't cause the master
-// to crash. See MESOS-8601.
+// a master failover and an agent reregistration won't cause the master
+// to crash, and frameworks recovered through agent reregistration will be
+// broadcast to subscribers. See MESOS-8601 and MESOS-9785.
 TEST_P(MasterAPITest, MasterFailover)
 {
   ContentType contentType = GetParam();
@@ -2733,15 +2734,24 @@ TEST_P(MasterAPITest, MasterFailover)
   EXPECT_CALL(subscriber, subscribed(_))
     .WillOnce(FutureArg<0>(&subscribedToMasterAPIEvents));
 
-  // The agent re-registration should result in an `AGENT_ADDED` event
-  // and a `TASK_ADDED` event.
-  Future<Nothing> taskAdded;
-  EXPECT_CALL(subscriber, taskAdded(_))
-    .WillOnce(FutureSatisfy(&taskAdded));
+  // The agent re-registration should result in an `AGENT_ADDED` event,
+  // a `FRAMEWORK_ADDED` event and a `TASK_ADDED` event in order.
+  Sequence masterEventsSequence;
 
-  Future<Nothing> agentAdded;
+  Future<v1::master::Event::AgentAdded> agentAdded;
   EXPECT_CALL(subscriber, agentAdded(_))
-    .WillOnce(FutureSatisfy(&agentAdded));
+    .InSequence(masterEventsSequence)
+    .WillOnce(FutureArg<0>(&agentAdded));
+
+  Future<v1::master::Event::FrameworkAdded> frameworkAdded;
+  EXPECT_CALL(subscriber, frameworkAdded(_))
+    .InSequence(masterEventsSequence)
+    .WillOnce(FutureArg<0>(&frameworkAdded));
+
+  Future<v1::master::Event::TaskAdded> taskAdded;
+  EXPECT_CALL(subscriber, taskAdded(_))
+    .InSequence(masterEventsSequence)
+    .WillOnce(FutureArg<0>(&taskAdded));
 
   // Create event stream after the master failover but before the agent
   // re-registration. We should see no framework, agent, task and
@@ -2764,8 +2774,18 @@ TEST_P(MasterAPITest, MasterFailover)
   Clock::advance(slaveFlags.registration_backoff_factor);
 
   AWAIT_READY(slaveReregisteredMessage);
-  AWAIT_READY(taskAdded);
+
   AWAIT_READY(agentAdded);
+  EXPECT_EQ(agentId, agentAdded->agent().agent_info().id());
+
+  AWAIT_READY(frameworkAdded);
+  EXPECT_EQ(frameworkId, frameworkAdded->framework().framework_info().id());
+  EXPECT_FALSE(frameworkAdded->framework().active());
+  EXPECT_FALSE(frameworkAdded->framework().connected());
+  EXPECT_TRUE(frameworkAdded->framework().recovered());
+
+  AWAIT_READY(taskAdded);
+  EXPECT_EQ(task.task_id(), taskAdded->task().task_id());
 }
 
 


[mesos] 01/03: Sequentialized all events to master's `/api/v1` subscribers.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 586dba870858129e5f6eaac58b7e1eb118196e26
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Wed May 22 21:08:09 2019 -0700

    Sequentialized all events to master's `/api/v1` subscribers.
    
    The master needs to create object approvers before sending an event to
    its `/api/v1` subscribers. The creation calls `process::collect`, which
    does not have any ordering guarantee. As a result, events might be
    reordered, which could be unexpected by subscribers.
    
    This patch imposes an order between events by sequentializing the
    creation of object approvers. The actual creations can still go in
    parallel, but the returned futures will be completed in the creation
    order.
    
    Review: https://reviews.apache.org/r/70702
---
 src/master/master.cpp | 15 +++++++++++++--
 src/master/master.hpp | 11 +++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/master/master.cpp b/src/master/master.cpp
index f1ca637..ace05b2 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -13177,9 +13177,8 @@ void Master::Subscribers::send(
   Shared<Task> sharedTask(task.isSome() ? new Task(task.get()) : nullptr);
 
   foreachvalue (const Owned<Subscriber>& subscriber, subscribed) {
-    ObjectApprovers::create(
+    subscriber->getApprovers(
         master->authorizer,
-        subscriber->principal,
         {VIEW_ROLE, VIEW_FRAMEWORK, VIEW_TASK, VIEW_EXECUTOR})
       .then(defer(
           master->self(),
@@ -13196,6 +13195,18 @@ void Master::Subscribers::send(
 }
 
 
+Future<Owned<ObjectApprovers>> Master::Subscribers::Subscriber::getApprovers(
+    const Option<Authorizer*>& authorizer,
+    std::initializer_list<authorization::Action> actions)
+{
+  Future<Owned<ObjectApprovers>> approvers =
+    ObjectApprovers::create(authorizer, principal, actions);
+
+  return approversSequence.add<Owned<ObjectApprovers>>(
+      [approvers] { return approvers; });
+}
+
+
 void Master::Subscribers::Subscriber::send(
     const Shared<mesos::master::Event>& event,
     const Owned<ObjectApprovers>& approvers,
diff --git a/src/master/master.hpp b/src/master/master.hpp
index ffa7423..5c229c5 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -50,6 +50,7 @@
 #include <process/owned.hpp>
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
+#include <process/sequence.hpp>
 #include <process/timer.hpp>
 
 #include <process/metrics/counter.hpp>
@@ -2265,6 +2266,12 @@ private:
       Subscriber(const Subscriber&) = delete;
       Subscriber& operator=(const Subscriber&) = delete;
 
+      // Creates object approvers. The futures returned by this method will be
+      // completed in the calling order.
+      process::Future<process::Owned<ObjectApprovers>> getApprovers(
+          const Option<Authorizer*>& authorizer,
+          std::initializer_list<authorization::Action> actions);
+
       // TODO(greggomann): Refactor this function into multiple event-specific
       // overloads. See MESOS-8475.
       void send(
@@ -2285,6 +2292,10 @@ private:
       StreamingHttpConnection<v1::master::Event> http;
       ResponseHeartbeater<mesos::master::Event, v1::master::Event> heartbeater;
       const Option<process::http::authentication::Principal> principal;
+
+      // We maintain a sequence to coordinate the creation of object approvers
+      // in order to sequentialize all events to the subscriber.
+      process::Sequence approversSequence;
     };
 
     // Sends the event to all subscribers connected to the 'api/vX' endpoint.