You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2024/04/16 17:12:31 UTC

(mesos) branch master updated (aed4041fd -> d821f758e)

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

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


    from aed4041fd  [cgroups2] Introduced an interface to set a hard memory limit.
     new 543c01ab5 Mitigate a case where the agent gets stuck sending TASK_DROPPED.
     new d821f758e Add a regression test for the mitigation of MESOS-7187.

The 2 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:
 src/master/master.cpp                           | 16 +++++
 src/tests/master_slave_reconciliation_tests.cpp | 87 +++++++++++++++++++++++++
 2 files changed, 103 insertions(+)


(mesos) 02/02: Add a regression test for the mitigation of MESOS-7187.

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

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

commit d821f758e60a5ede3b1146818767f9d1c8c7cb0a
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Mon Apr 15 18:01:16 2024 -0400

    Add a regression test for the mitigation of MESOS-7187.
---
 src/tests/master_slave_reconciliation_tests.cpp | 87 +++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/src/tests/master_slave_reconciliation_tests.cpp b/src/tests/master_slave_reconciliation_tests.cpp
index 9881b9c08..a14846975 100644
--- a/src/tests/master_slave_reconciliation_tests.cpp
+++ b/src/tests/master_slave_reconciliation_tests.cpp
@@ -32,6 +32,8 @@
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
 
+#include <stout/uuid.hpp>
+
 #include "common/protobuf_utils.hpp"
 
 #include "master/master.hpp"
@@ -1161,6 +1163,91 @@ TEST_F(MasterSlaveReconciliationTest, SlaveReregisterTaskExecutorIds)
   driver.join();
 }
 
+
+// This tests one particular issue that's caused by MESOS-7187 whereby the
+// following occurred:
+//
+// 1. ZK session expired
+// 2. Master failover
+// 3. Agent run 1 sends re-registration message to new master with
+//    resource UUID 1.
+// 4. Agent fails over (for upgrade)
+// 5. Agent run 2 sends re-registration message to new master with
+//    resource UUID 2.
+// 6. Master receives run 1 re-registration message.
+// 7. Master ignores run 2 re-registration message
+//    (as agent is already re-registering).
+// 8. Master completes re-registration and stores resource UUID 1 and notifies agent.
+// 9. Agent receives re-registration completion, sends resource update with UUID 2.
+// 10. Master does not update the agent's resource UUID
+//    (not because it ignores the update message, but because the logic simply
+//    wasn't making any update to it), so it remains UUID 1.
+//
+// Now with the fix we expect the master to have updated the UUID, although
+// note that the fix isn't a complete fix for MESOS-7187, rather just fixes
+// the resource UUID mismatch.
+TEST_F(MasterSlaveReconciliationTest, SlaveReregistrationRace_MESOS_7187)
+{
+  Try<Owned<cluster::Master>> master = StartMaster();
+  ASSERT_SOME(master);
+
+  // Start an agent, but intercept the resource update message so that
+  // we can inject a new resource UUID and ensure the master stores it.
+  Future<UpdateSlaveMessage> updateSlaveMessage =
+    DROP_PROTOBUF(UpdateSlaveMessage(), _, _);
+
+  slave::Flags flags = CreateSlaveFlags();
+  StandaloneMasterDetector detector(master.get()->pid);
+  Try<Owned<cluster::Slave>> slave = StartSlave(&detector, flags);
+  ASSERT_SOME(slave);
+
+  AWAIT_READY(updateSlaveMessage);
+
+  // Now send the update with a tweaked resource UUID.
+  id::UUID uuid = id::UUID::random();
+  UpdateSlaveMessage updateCopy = updateSlaveMessage.get();
+  updateCopy.mutable_resource_version_uuid()->set_value(uuid.toBytes());
+  process::post(slave.get()->pid, master.get()->pid, updateCopy);
+
+  // Now launch a task and check that the resource version is our
+  // mutated version.
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  Future<vector<Offer>> offers;
+  EXPECT_CALL(sched, resourceOffers(&driver, _))
+    .WillOnce(FutureArg<1>(&offers))
+    .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+  driver.start();
+
+  AWAIT_READY(frameworkId);
+
+  AWAIT_READY(offers);
+  EXPECT_NE(0u, offers->size());
+
+  Future<RunTaskMessage> runTaskMessage =
+    DROP_PROTOBUF(RunTaskMessage(), _, _);
+
+  const Offer& offer = offers->front();
+  TaskInfo task = createTask(offer, "echo hi");
+  driver.launchTasks(offer.id(), {task});
+
+  AWAIT_READY(runTaskMessage);
+
+  ASSERT_EQ(1, runTaskMessage->resource_version_uuids_size());
+  EXPECT_FALSE(
+      runTaskMessage->resource_version_uuids(0).has_resource_provider_id());
+  EXPECT_EQ(
+      uuid.toBytes(), runTaskMessage->resource_version_uuids(0).uuid().value());
+}
+
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {


(mesos) 01/02: Mitigate a case where the agent gets stuck sending TASK_DROPPED.

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

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

commit 543c01ab5c59695795fc6c7e6fc5bc02c3524121
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Mon Apr 15 14:44:36 2024 -0400

    Mitigate a case where the agent gets stuck sending TASK_DROPPED.
    
    Per MESOS-7187, there is a case where the master holds a stale resource
    UUID for the agent's resources, and all subsequent task launches result
    in the agent sending TASK_DROPPED due to "Task assumes outdated resource
    state".
    
    While this patch doesn't fix the general issue of MESOS-7187, it does
    mitigate a known problematic case due to the introduction of the agent
    having its own resource UUID.
---
 src/master/master.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/master/master.cpp b/src/master/master.cpp
index 4a601c97e..e4f40104a 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -7746,6 +7746,22 @@ void Master::updateSlave(UpdateSlaveMessage&& message)
     // providers as well.
   }
 
+  // We don't expect the agent's resource version to change, but above we
+  // do have a check to see if it's changed and therefore set `updated`
+  // to true, so we might as well assign the new value here rather than
+  // ignore it.
+  //
+  // Now that we have resource versions in the agent, the lack of the
+  // update to the version here was causing MESOS-7187 to be triggered
+  // when the master receives a re-registration message from the old run
+  // of an agent and then ignores the new re-registration message from a
+  // new run of the agent. When the new agent sends the update message,
+  // the master was seeing the different resource uuid and setting
+  // `updated`, but wasn't actually setting the new version.
+  if (message.has_resource_version_uuid()) {
+    slave->resourceVersion = message.resource_version_uuid();
+  }
+
   ReconcileOperationsMessage reconcile;
 
   // Reconcile operations on agent-default resources.