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 2014/11/20 21:50:47 UTC

[1/3] mesos git commit: Updated killTask to perform reconciliation for unknown tasks.

Repository: mesos
Updated Branches:
  refs/heads/master b2809624d -> f0e242213


Updated killTask to perform reconciliation for unknown tasks.

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


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

Branch: refs/heads/master
Commit: f0e242213917188f207f9c519413c8164ec23456
Parents: b51e4ed
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Nov 19 16:08:27 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Nov 20 12:49:49 2014 -0800

----------------------------------------------------------------------
 src/master/master.cpp              | 50 ++++-----------------------------
 src/tests/reconciliation_tests.cpp | 42 +++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f0e24221/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 2b01af4..5957db6 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2752,52 +2752,14 @@ void Master::killTask(
 
   Task* task = framework->getTask(taskId);
   if (task == NULL) {
-    // TODO(bmahler): Per MESOS-1200, if we knew the SlaveID here we
-    // could reply more frequently in the presence of slaves in a
-    // transitionary state.
-    if (!slaves.recovered.empty()) {
-      LOG(WARNING)
-        << "Cannot kill task " << taskId << " of framework " << *framework
-        << " because the slave containing this task may not have re-registered"
-        << " yet with this master";
-    } else if (!slaves.reregistering.empty()) {
-      LOG(WARNING)
-        << "Cannot kill task " << taskId << " of framework " << *framework
-        << " because the slave may be in the process of being re-admitted by"
-        << " the registrar";
-    } else if (!slaves.removing.empty()) {
-      LOG(WARNING)
-        << "Cannot kill task " << taskId << " of framework " << *framework
-        << " because the slave may be in the process of being removed from the"
-        << " registrar, it is likely TASK_LOST updates will occur when the"
-        << " slave is removed";
-    } else if (flags.registry_strict) {
-      // For a strict registry, if there are no slaves transitioning
-      // between states, then this task is definitely unknown!
-      LOG(WARNING)
-        << "Cannot kill task " << taskId << " of framework " << *framework
-        << " because it cannot be found; sending TASK_LOST since there are"
-        << " no transitionary slaves";
-
-      const StatusUpdate& update = protobuf::createStatusUpdate(
-          frameworkId,
-          None(),
-          taskId,
-          TASK_LOST,
-          TaskStatus::SOURCE_MASTER,
-          "Attempted to kill an unknown task",
-          TaskStatus::REASON_TASK_UNKNOWN);
+    LOG(WARNING) << "Cannot kill task " << taskId
+                 << " of framework " << *framework
+                 << " because it is unknown; performing reconciliation";
 
-      forward(update, UPID(), framework);
-    } else {
-      // For a non-strict registry, the slave holding this task could
-      // be readmitted even if we have no knowledge of it.
-      LOG(WARNING)
-        << "Cannot kill task " << taskId << " of framework " << *framework
-        << " because it cannot be found; cannot send TASK_LOST since a"
-        << " non-strict registry is in use";
-    }
+    TaskStatus status;
+    status.mutable_task_id()->CopyFrom(taskId);
 
+    _reconcileTasks(framework, {status});
     return;
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/f0e24221/src/tests/reconciliation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/reconciliation_tests.cpp b/src/tests/reconciliation_tests.cpp
index d153152..c21f4cb 100644
--- a/src/tests/reconciliation_tests.cpp
+++ b/src/tests/reconciliation_tests.cpp
@@ -333,6 +333,48 @@ TEST_F(ReconciliationTest, UnknownTask)
 }
 
 
+// This test verifies that the killTask request of an unknown task
+// results in reconciliation. In this case, the task is unknown
+// and there are no transitional slaves.
+TEST_F(ReconciliationTest, UnknownKillTask)
+{
+  Try<PID<Master> > master = StartMaster();
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+    &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  driver.start();
+
+  // Wait until the framework is registered.
+  AWAIT_READY(frameworkId);
+
+  Future<TaskStatus> update;
+  EXPECT_CALL(sched, statusUpdate(&driver, _))
+    .WillOnce(FutureArg<1>(&update));
+
+  vector<TaskStatus> statuses;
+
+  // Create a task status with a random task id.
+  TaskID taskId;
+  taskId.set_value(UUID::random().toString());
+
+  driver.killTask(taskId);
+
+  // Framework should receive TASK_LOST for unknown task.
+  AWAIT_READY(update);
+  EXPECT_EQ(TASK_LOST, update.get().state());
+
+  driver.stop();
+  driver.join();
+}
+
+
 // This test verifies that reconciliation of a task that belongs to a
 // slave that is a transitional state doesn't result in an update.
 TEST_F(ReconciliationTest, SlaveInTransition)


[2/3] mesos git commit: Added a task reconciliation continuation for re-use in the Master.

Posted by bm...@apache.org.
Added a task reconciliation continuation for re-use in the Master.

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


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

Branch: refs/heads/master
Commit: b51e4ed2d25d69b7e21acfe58ca5ac367a6fc349
Parents: 74e1d9b
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Nov 19 16:07:25 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Nov 20 12:49:49 2014 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 30 ++++++++++++++++++++----------
 src/master/master.hpp |  6 ++++++
 2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b51e4ed2/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index de42f8e..2b01af4 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3552,14 +3552,24 @@ void Master::reconcileTasks(
     return;
   }
 
+  _reconcileTasks(framework, statuses);
+}
+
+
+void Master::_reconcileTasks(
+    Framework* framework,
+    const vector<TaskStatus>& statuses)
+{
+  CHECK_NOTNULL(framework);
+
   if (statuses.empty()) {
     // Implicit reconciliation.
-    LOG(INFO) << "Performing implicit task state reconciliation for framework "
-              << *framework;
+    LOG(INFO) << "Performing implicit task state reconciliation"
+                 " for framework " << *framework;
 
     foreachvalue (const TaskInfo& task, framework->pendingTasks) {
       const StatusUpdate& update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task.slave_id(),
           task.task_id(),
           TASK_STAGING,
@@ -3585,7 +3595,7 @@ void Master::reconcileTasks(
           : task->state();
 
       const StatusUpdate& update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task->slave_id(),
           task->task_id(),
           state,
@@ -3638,7 +3648,7 @@ void Master::reconcileTasks(
       // (1) Task is known, but pending: TASK_STAGING.
       const TaskInfo& task_ = framework->pendingTasks[status.task_id()];
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task_.slave_id(),
           task_.task_id(),
           TASK_STAGING,
@@ -3652,7 +3662,7 @@ void Master::reconcileTasks(
           : task->state();
 
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task->slave_id(),
           task->task_id(),
           state,
@@ -3662,7 +3672,7 @@ void Master::reconcileTasks(
     } else if (slaveId.isSome() && slaves.registered.contains(slaveId.get())) {
       // (3) Task is unknown, slave is registered: TASK_LOST.
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           slaveId.get(),
           status.task_id(),
           TASK_LOST,
@@ -3671,13 +3681,13 @@ void Master::reconcileTasks(
           TaskStatus::REASON_RECONCILIATION);
     } else if (slaves.transitioning(slaveId)) {
       // (4) Task is unknown, slave is transitionary: no-op.
-      LOG(INFO) << "Ignoring reconciliation request of task "
-                << status.task_id() << " from framework " << *framework
+      LOG(INFO) << "Dropping reconciliation of task " << status.task_id()
+                << " for framework " << *framework
                 << " because there are transitional slaves";
     } else {
       // (5) Task is unknown, slave is unknown: TASK_LOST.
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           slaveId,
           status.task_id(),
           TASK_LOST,

http://git-wip-us.apache.org/repos/asf/mesos/blob/b51e4ed2/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index ece36c3..6eabb07 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -286,6 +286,12 @@ protected:
   // Invoked when the contender has entered the contest.
   void contended(const process::Future<process::Future<Nothing>>& candidacy);
 
+  // Task reconciliation, split from the message handler
+  // to allow re-use.
+  void _reconcileTasks(
+      Framework* framework,
+      const std::vector<TaskStatus>& statuses);
+
   // Handles a known re-registering slave by reconciling the master's
   // view of the slave's tasks and executors.
   void reconcile(


[3/3] mesos git commit: Removed unnecessary calls to Shutdown() in the reconciliation tests.

Posted by bm...@apache.org.
Removed unnecessary calls to Shutdown() in the reconciliation tests.

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


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

Branch: refs/heads/master
Commit: 74e1d9bfb8976113c0e7833f8f4909566b044b63
Parents: b280962
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Nov 19 16:00:48 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Nov 20 12:49:49 2014 -0800

----------------------------------------------------------------------
 src/tests/reconciliation_tests.cpp | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/74e1d9bf/src/tests/reconciliation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/reconciliation_tests.cpp b/src/tests/reconciliation_tests.cpp
index 4ba5394..d153152 100644
--- a/src/tests/reconciliation_tests.cpp
+++ b/src/tests/reconciliation_tests.cpp
@@ -272,8 +272,6 @@ TEST_F(ReconciliationTest, UnknownSlave)
 
   driver.stop();
   driver.join();
-
-  Shutdown();
 }
 
 
@@ -332,8 +330,6 @@ TEST_F(ReconciliationTest, UnknownTask)
 
   driver.stop();
   driver.join();
-
-  Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
 }
 
 
@@ -426,8 +422,6 @@ TEST_F(ReconciliationTest, SlaveInTransition)
 
   driver.stop();
   driver.join();
-
-  Shutdown();
 }
 
 
@@ -661,8 +655,6 @@ TEST_F(ReconciliationTest, PendingTask)
 
   driver.stop();
   driver.join();
-
-  Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
 }
 
 
@@ -853,5 +845,5 @@ TEST_F(ReconciliationTest, ReconcileStatusUpdateTaskState)
   driver.stop();
   driver.join();
 
-  Shutdown();
+  Shutdown(); // Must shutdown before the detector gets de-allocated.
 }