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:12:30 UTC
[mesos] branch 1.7.x updated (511bfc3 -> 8e8c6c0)
This is an automated email from the ASF dual-hosted git repository.
chhsiao pushed a change to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git.
from 511bfc3 Added MESOS-9870 to the 1.7.3 CHANGELOG.
new 17dea04 Sequentialized all events to master's `/api/v1` subscribers.
new c3ed9ae Notifies master `/api/v1` subscribers about recovered frameworks.
new 8e8c6c0 Added MESOS-9785 to the 1.7.3 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 | 1 +
src/common/protobuf_utils.cpp | 4 ----
src/master/master.cpp | 22 ++++++++++++++++++++--
src/master/master.hpp | 11 +++++++++++
src/tests/api_tests.cpp | 35 +++++++++++++++++++++++++----------
5 files changed, 57 insertions(+), 16 deletions(-)
[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 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 17dea045f24c391ce7645a001338ffbc44ec55e6
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 479d56c..0564025 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -12065,9 +12065,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(),
@@ -12084,6 +12083,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 2bfe255..6830e3b 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -58,6 +58,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>
@@ -2134,6 +2135,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(
@@ -2158,6 +2165,10 @@ private:
process::Owned<Heartbeater<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.
[mesos] 03/03: Added MESOS-9785 to the 1.7.3 CHANGELOG.
Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
chhsiao pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 8e8c6c0820e1edd954ce07aa530aa64ad323f3d6
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Wed May 22 14:45:02 2019 -0700
Added MESOS-9785 to the 1.7.3 CHANGELOG.
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index fcdf1e9..7bee655 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@ Release Notes - Mesos - Version 1.7.3 (WIP)
* [MESOS-9707] - Calling link::lo() may cause runtime error
* [MESOS-9750] - Agent V1 GET_STATE response may report a complete executor's tasks as non-terminal after a graceful agent shutdown.
* [MESOS-9766] - /__processes__ endpoint can hang.
+ * [MESOS-9785] - Frameworks recovered from reregistered agents are not reported to master `/api/v1` subscribers.
* [MESOS-9786] - Race between two REMOVE_QUOTA calls crashes the master.
* [MESOS-9787] - Log slow SSL (TLS) peer reverse DNS lookup.
* [MESOS-9803] - Memory leak caused by an infinite chain of futures in `UriDiskProfileAdaptor`.
[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 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit c3ed9ae5a0791cbc83cc0679d924da5b7cc6caa1
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 | 35 +++++++++++++++++++++++++----------
3 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index b9289a2..138bee6 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -1211,10 +1211,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 0564025..3f0c8c0 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -10094,6 +10094,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 d6a8f82..0cfc8e3 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -2539,8 +2539,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();
@@ -2691,21 +2692,35 @@ TEST_P(MasterAPITest, MasterFailover)
AWAIT_READY(slaveReregisteredMessage);
- // The agent re-registration should result in an `AGENT_ADDED` event
- // and a `TASK_ADDED` event.
- set<v1::master::Event::Type> expectedEvents =
- {v1::master::Event::AGENT_ADDED, v1::master::Event::TASK_ADDED};
- set<v1::master::Event::Type> observedEvents;
+ // The agent re-registration should result in an `AGENT_ADDED` event,
+ // a `FRAMEWORK_ADDED` event and a `TASK_ADDED` event in order.
+ event = decoder.read();
+ AWAIT_READY(event);
+
+ EXPECT_EQ(v1::master::Event::AGENT_ADDED, event.get()->type());
+ const v1::master::Event::AgentAdded& agentAdded = event.get()->agent_added();
+
+ EXPECT_EQ(agentId, agentAdded.agent().agent_info().id());
event = decoder.read();
AWAIT_READY(event);
- observedEvents.insert(event->get().type());
+
+ EXPECT_EQ(v1::master::Event::FRAMEWORK_ADDED, event.get()->type());
+ const v1::master::Event::FrameworkAdded& frameworkAdded =
+ event.get()->framework_added();
+
+ EXPECT_EQ(frameworkId, frameworkAdded.framework().framework_info().id());
+ EXPECT_FALSE(frameworkAdded.framework().active());
+ EXPECT_FALSE(frameworkAdded.framework().connected());
+ EXPECT_TRUE(frameworkAdded.framework().recovered());
event = decoder.read();
AWAIT_READY(event);
- observedEvents.insert(event->get().type());
- EXPECT_EQ(expectedEvents, observedEvents);
+ EXPECT_EQ(v1::master::Event::TASK_ADDED, event.get()->type());
+ const v1::master::Event::TaskAdded& taskAdded = event.get()->task_added();
+
+ EXPECT_EQ(task.task_id(), taskAdded.task().task_id());
}