You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/12/02 21:29:08 UTC

[01/10] mesos git commit: Removed stuttering from teardown test names.

Repository: mesos
Updated Branches:
  refs/heads/master d32de003a -> 0ff163246


Removed stuttering from teardown test names.

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


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

Branch: refs/heads/master
Commit: b83add1d34e83fb70c345fac00bc90581ba849ad
Parents: d32de00
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:27:54 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:27:54 2016 -0800

----------------------------------------------------------------------
 docs/working-groups.md       |  1 +
 src/tests/teardown_tests.cpp | 14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b83add1d/docs/working-groups.md
----------------------------------------------------------------------
diff --git a/docs/working-groups.md b/docs/working-groups.md
index a03a9aa..ebf4776 100644
--- a/docs/working-groups.md
+++ b/docs/working-groups.md
@@ -4,6 +4,7 @@ layout: documentation
 ---
 
 # Working Groups
+
 * **External Volumes**
 	* members:
 		* Adam B

http://git-wip-us.apache.org/repos/asf/mesos/blob/b83add1d/src/tests/teardown_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/teardown_tests.cpp b/src/tests/teardown_tests.cpp
index 0babf8c..b14816f 100644
--- a/src/tests/teardown_tests.cpp
+++ b/src/tests/teardown_tests.cpp
@@ -60,7 +60,7 @@ class TeardownTest : public MesosTest {};
 // the designated framework or returns an appropriate error.
 
 // Testing route with authorization header and good credentials.
-TEST_F(TeardownTest, TeardownEndpoint)
+TEST_F(TeardownTest, Success)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
@@ -92,7 +92,7 @@ TEST_F(TeardownTest, TeardownEndpoint)
 
 
 // Testing route with bad credentials.
-TEST_F(TeardownTest, TeardownEndpointBadCredentials)
+TEST_F(TeardownTest, BadCredentials)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
@@ -128,7 +128,7 @@ TEST_F(TeardownTest, TeardownEndpointBadCredentials)
 
 
 // Testing route with good ACLs.
-TEST_F(TeardownTest, TeardownEndpointGoodACLs)
+TEST_F(TeardownTest, GoodACLs)
 {
   // Setup ACLs so that the default principal can teardown the
   // framework.
@@ -172,7 +172,7 @@ TEST_F(TeardownTest, TeardownEndpointGoodACLs)
 
 // Testing route with deprecated (but still good) ACLs.
 // This ACL/test will be removed at the end of the deprecation cycle on 0.27.
-TEST_F(TeardownTest, TeardownEndpointGoodDeprecatedACLs)
+TEST_F(TeardownTest, GoodDeprecatedACLs)
 {
   // Setup ACLs so that the default principal can teardown the
   // framework.
@@ -215,7 +215,7 @@ TEST_F(TeardownTest, TeardownEndpointGoodDeprecatedACLs)
 
 
 // Testing route with bad ACLs.
-TEST_F(TeardownTest, TeardownEndpointBadACLs)
+TEST_F(TeardownTest, BadACLs)
 {
   // Setup ACLs so that no principal can teardown the framework.
   ACLs acls;
@@ -257,7 +257,7 @@ TEST_F(TeardownTest, TeardownEndpointBadACLs)
 
 
 // Testing route without frameworkId value.
-TEST_F(TeardownTest, TeardownEndpointNoFrameworkId)
+TEST_F(TeardownTest, NoFrameworkId)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
@@ -289,7 +289,7 @@ TEST_F(TeardownTest, TeardownEndpointNoFrameworkId)
 
 
 // Testing route without authorization header.
-TEST_F(TeardownTest, TeardownEndpointNoHeader)
+TEST_F(TeardownTest, NoHeader)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);


[08/10] mesos git commit: Fixed typo, removed hard tab character.

Posted by vi...@apache.org.
Fixed typo, removed hard tab character.

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


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

Branch: refs/heads/master
Commit: 9b6ebc3e2200176ec1fbe15a015af2a91d08fce1
Parents: f9b3c6b
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:37 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:37 2016 -0800

----------------------------------------------------------------------
 include/mesos/master/master.proto    | 4 ++--
 include/mesos/v1/master/master.proto | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9b6ebc3e/include/mesos/master/master.proto
----------------------------------------------------------------------
diff --git a/include/mesos/master/master.proto b/include/mesos/master/master.proto
index 3553c68..966105c 100644
--- a/include/mesos/master/master.proto
+++ b/include/mesos/master/master.proto
@@ -360,7 +360,7 @@ message Response {
   // time. Note that there might be tasks unknown to the master running on
   // partitioned or unsubscribed agents.
   message GetTasks {
-    // Tasks that are an enqueued on the master waiting (e.g., authorizing)
+    // Tasks that are enqueued on the master waiting (e.g., authorizing)
     // to be launched.
     repeated Task pending_tasks = 1;
 
@@ -466,7 +466,7 @@ message Event {
     required FrameworkID framework_id = 1;
 
     // This is the status of the task corresponding to the last
-		// status update acknowledged by the scheduler.
+    // status update acknowledged by the scheduler.
     required TaskStatus status = 2;
 
     // This is the latest state of the task according to the agent.

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b6ebc3e/include/mesos/v1/master/master.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/master/master.proto b/include/mesos/v1/master/master.proto
index 022b491..0e5a867 100644
--- a/include/mesos/v1/master/master.proto
+++ b/include/mesos/v1/master/master.proto
@@ -361,7 +361,7 @@ message Response {
   // time. Note that there might be tasks unknown to the master running on
   // partitioned or unsubscribed agents.
   message GetTasks {
-    // Tasks that are an enqueued on the master waiting (e.g., authorizing)
+    // Tasks that are enqueued on the master waiting (e.g., authorizing)
     // to be launched.
     repeated Task pending_tasks = 1;
 
@@ -466,8 +466,8 @@ message Event {
   message TaskUpdated {
     required FrameworkID framework_id = 1;
 
-		// This is the status of the task corresponding to the last
-		// status update acknowledged by the scheduler.
+    // This is the status of the task corresponding to the last
+    // status update acknowledged by the scheduler.
     required TaskStatus status = 2;
 
     // This is the latest state of the task according to the agent.


[02/10] mesos git commit: Improved TeardownTest.Success.

Posted by vi...@apache.org.
Improved TeardownTest.Success.

Check that when a framework is shutdown, this is appropriately reflected
in the content of the master's "/state" endpoint.

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


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

Branch: refs/heads/master
Commit: 4b9dd048fda7fa10b40e289435cc5376b77375a2
Parents: b83add1
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:00 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:00 2016 -0800

----------------------------------------------------------------------
 src/tests/teardown_tests.cpp | 49 +++++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4b9dd048/src/tests/teardown_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/teardown_tests.cpp b/src/tests/teardown_tests.cpp
index b14816f..125e180 100644
--- a/src/tests/teardown_tests.cpp
+++ b/src/tests/teardown_tests.cpp
@@ -77,14 +77,49 @@ TEST_F(TeardownTest, Success)
 
   AWAIT_READY(frameworkId);
 
-  Future<Response> response = process::http::post(
-      master.get()->pid,
-      "teardown",
-      createBasicAuthHeaders(DEFAULT_CREDENTIAL),
-      "frameworkId=" + frameworkId.get().value());
+  {
+    Future<Response> response = process::http::post(
+        master.get()->pid,
+        "teardown",
+        createBasicAuthHeaders(DEFAULT_CREDENTIAL),
+        "frameworkId=" + frameworkId.get().value());
 
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+    AWAIT_READY(response);
+    AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  }
+
+  // Check that the framework that was shutdown appears in the
+  // "completed_frameworks" list in the master's "/state" endpoint.
+  {
+    Future<Response> response = process::http::get(
+        master.get()->pid,
+        "state",
+        None(),
+        createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+    AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+    AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
+
+    Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
+    ASSERT_SOME(parse);
+
+    JSON::Array frameworks = parse->values["frameworks"].as<JSON::Array>();
+
+    EXPECT_TRUE(frameworks.values.empty());
+
+    JSON::Array completedFrameworks =
+      parse->values["completed_frameworks"].as<JSON::Array>();
+
+    ASSERT_EQ(1u, completedFrameworks.values.size());
+
+    JSON::Object completedFramework =
+      completedFrameworks.values.front().as<JSON::Object>();
+
+    JSON::String completedFrameworkId =
+      completedFramework.values["id"].as<JSON::String>();
+
+    EXPECT_EQ(frameworkId.get(), completedFrameworkId.value);
+  }
 
   driver.stop();
   driver.join();


[07/10] mesos git commit: Replaced "slave" with "agent" in status update messages.

Posted by vi...@apache.org.
Replaced "slave" with "agent" in status update messages.

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


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

Branch: refs/heads/master
Commit: f9b3c6b69866a295c09067b236bda728e130682e
Parents: 432165f
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:30 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:30 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f9b3c6b6/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 7417651..999c2c4 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6088,7 +6088,7 @@ void Master::_markUnreachable(
           newTaskState,
           TaskStatus::SOURCE_MASTER,
           None(),
-          "Slave " + slave->info.hostname() + " is unreachable",
+          "Agent " + slave->info.hostname() + " is unreachable",
           TaskStatus::REASON_SLAVE_REMOVED,
           (task->has_executor_id() ?
               Option<ExecutorID>(task->executor_id()) : None()),
@@ -7351,7 +7351,7 @@ void Master::removeFramework(Slave* slave, Framework* framework)
         TASK_LOST,
         TaskStatus::SOURCE_MASTER,
         None(),
-        "Slave " + slave->info.hostname() + " disconnected",
+        "Agent " + slave->info.hostname() + " disconnected",
         TaskStatus::REASON_SLAVE_DISCONNECTED,
         (task->has_executor_id()
             ? Option<ExecutorID>(task->executor_id()) : None()));
@@ -7583,7 +7583,7 @@ void Master::_removeSlave(
           TASK_LOST,
           TaskStatus::SOURCE_MASTER,
           None(),
-          "Slave " + slave->info.hostname() + " removed: " + removalCause,
+          "Agent " + slave->info.hostname() + " removed: " + removalCause,
           TaskStatus::REASON_SLAVE_REMOVED,
           (task->has_executor_id() ?
               Option<ExecutorID>(task->executor_id()) : None()));


[09/10] mesos git commit: Avoided sending `LostSlaveMessage` to disconnected frameworks.

Posted by vi...@apache.org.
Avoided sending `LostSlaveMessage` to disconnected frameworks.

Since we don't attempt to send messages to disconnected frameworks, this
would only have resulted in a warning message in the master logs anyway.

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


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

Branch: refs/heads/master
Commit: d73cc381b60c13d2055e57a8a58e639d8ec4385c
Parents: 9b6ebc3
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:42 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:42 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d73cc381/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 999c2c4..203567c 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1953,6 +1953,10 @@ void Master::_markUnreachableAfterFailover(
 void Master::sendSlaveLost(const SlaveInfo& slaveInfo)
 {
   foreachvalue (Framework* framework, frameworks.registered) {
+    if (!framework->connected) {
+      continue;
+    }
+
     LOG(INFO) << "Notifying framework " << *framework << " of lost agent "
               << slaveInfo.id() << " (" << slaveInfo.hostname() << ")";
 


[06/10] mesos git commit: Tweaked usage of `getFramework`.

Posted by vi...@apache.org.
Tweaked usage of `getFramework`.

In a few places, calls to `getFramework` can be hoisted out of an inner
loop. This improves code clarity (as well as maybe saving a few cycles).

A call to `getFramework` can be hoisted out of an inner loop.

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


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

Branch: refs/heads/master
Commit: 432165f3ff9259204e0d65db10b3aa1dba42b2af
Parents: 9ccfa5c
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:23 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:23 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/432165f3/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index b015b8d..7417651 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -7405,20 +7405,24 @@ void Master::addSlave(
 
   // Add the slave's executors to the frameworks.
   foreachkey (const FrameworkID& frameworkId, slave->executors) {
+    Framework* framework = getFramework(frameworkId);
+
+    // The framework might not be re-registered yet.
+    if (framework == nullptr) {
+      continue;
+    }
+
     foreachvalue (const ExecutorInfo& executorInfo,
                   slave->executors[frameworkId]) {
-      Framework* framework = getFramework(frameworkId);
-      // The framework might not be re-registered yet.
-      if (framework != nullptr) {
-        framework->addExecutor(slave->id, executorInfo);
-      }
+      framework->addExecutor(slave->id, executorInfo);
     }
   }
 
   // Add the slave's tasks to the frameworks.
   foreachkey (const FrameworkID& frameworkId, slave->tasks) {
+    Framework* framework = getFramework(frameworkId);
+
     foreachvalue (Task* task, slave->tasks[frameworkId]) {
-      Framework* framework = getFramework(task->framework_id());
       // The framework might not be re-registered yet.
       if (framework != nullptr) {
         framework->addTask(task);
@@ -7569,6 +7573,8 @@ void Master::_removeSlave(
 
   // Transition the tasks to lost and remove them.
   foreachkey (const FrameworkID& frameworkId, utils::copy(slave->tasks)) {
+    Framework* framework = getFramework(frameworkId);
+
     foreachvalue (Task* task, utils::copy(slave->tasks[frameworkId])) {
       const StatusUpdate& update = protobuf::createStatusUpdate(
           task->framework_id(),
@@ -7585,7 +7591,6 @@ void Master::_removeSlave(
       updateTask(task, update);
       removeTask(task);
 
-      Framework* framework = getFramework(frameworkId);
       if (framework == nullptr) {
         LOG(WARNING) << "Dropping update " << update
                      << " for unknown framework " << frameworkId;


[10/10] mesos git commit: Added helper function, `Master::isCompletedFramework`.

Posted by vi...@apache.org.
Added helper function, `Master::isCompletedFramework`.

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


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

Branch: refs/heads/master
Commit: 0ff163246f29006e0fb07a52f6842ae9cf7efa19
Parents: d73cc38
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:48 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:48 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 56 +++++++++++++++++++++++++---------------------
 src/master/master.hpp |  2 ++
 2 files changed, 32 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0ff16324/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 203567c..c2c08e1 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2354,19 +2354,15 @@ void Master::subscribe(
                             " without --root_submissions set");
   }
 
-  if (validationError.isNone() && frameworkInfo.has_id()) {
-    foreach (const shared_ptr<Framework>& framework, frameworks.completed) {
-      if (framework->id() == frameworkInfo.id()) {
-        // This could happen if a framework tries to subscribe after
-        // its failover timeout has elapsed or it unregistered itself
-        // by calling 'stop()' on the scheduler driver.
-        //
-        // TODO(vinod): Master should persist admitted frameworks to the
-        // registry and remove them from it after failover timeout.
-        validationError = Error("Framework has been removed");
-        break;
-      }
-    }
+  if (validationError.isNone() && frameworkInfo.has_id() &&
+      isCompletedFramework(frameworkInfo.id())) {
+    // This could happen if a framework tries to subscribe after its
+    // failover timeout has elapsed or it unregistered itself by
+    // calling 'stop()' on the scheduler driver.
+    //
+    // TODO(vinod): Master should persist admitted frameworks to the
+    // registry and remove them from it after failover timeout.
+    validationError = Error("Framework has been removed");
   }
 
   if (validationError.isNone() && !isValidFailoverTimeout(frameworkInfo)) {
@@ -2583,19 +2579,15 @@ void Master::subscribe(
                             " without --root_submissions set");
   }
 
-  if (validationError.isNone() && frameworkInfo.has_id()) {
-    foreach (const shared_ptr<Framework>& framework, frameworks.completed) {
-      if (framework->id() == frameworkInfo.id()) {
-        // This could happen if a framework tries to subscribe after
-        // its failover timeout has elapsed or it unregistered itself
-        // by calling 'stop()' on the scheduler driver.
-        //
-        // TODO(vinod): Master should persist admitted frameworks to the
-        // registry and remove them from it after failover timeout.
-        validationError = Error("Framework has been removed");
-        break;
-      }
-    }
+  if (validationError.isNone() && frameworkInfo.has_id() &&
+      isCompletedFramework(frameworkInfo.id())) {
+    // This could happen if a framework tries to subscribe after its
+    // failover timeout has elapsed or it unregistered itself by
+    // calling 'stop()' on the scheduler driver.
+    //
+    // TODO(vinod): Master should persist admitted frameworks to the
+    // registry and remove them from it after failover timeout.
+    validationError = Error("Framework has been removed");
   }
 
   if (validationError.isNone() && !isValidFailoverTimeout(frameworkInfo)) {
@@ -8005,6 +7997,18 @@ void Master::removeInverseOffer(InverseOffer* inverseOffer, bool rescind)
 }
 
 
+bool Master::isCompletedFramework(const FrameworkID& frameworkId)
+{
+  foreach (const shared_ptr<Framework>& framework, frameworks.completed) {
+    if (framework->id() == frameworkId) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+
 // TODO(bmahler): Consider killing this.
 Framework* Master::getFramework(const FrameworkID& frameworkId)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/0ff16324/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 5114e9d..f4be5e5 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -860,6 +860,8 @@ protected:
   // Remove an inverse offer and optionally rescind it as well.
   void removeInverseOffer(InverseOffer* inverseOffer, bool rescind = false);
 
+  bool isCompletedFramework(const FrameworkID& frameworkId);
+
   Framework* getFramework(const FrameworkID& frameworkId);
   Offer* getOffer(const OfferID& offerId);
   InverseOffer* getInverseOffer(const OfferID& inverseOfferId);


[05/10] mesos git commit: Improved comments in the master.

Posted by vi...@apache.org.
Improved comments in the master.

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


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

Branch: refs/heads/master
Commit: 9ccfa5c1ecf6fc6374dba1709ac837874384cdc3
Parents: 4cc4fe4
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:15 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:15 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9ccfa5c1/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index e03a2e8..b015b8d 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1262,12 +1262,18 @@ void Master::exited(const UPID& pid)
 
       // The semantics when a registered slave gets disconnected are as
       // follows for each framework running on that slave:
-      // 1) If the framework is checkpointing: No immediate action is taken.
-      //    The slave is given a chance to reconnect until the slave
-      //    observer times out (75s) and removes the slave.
-      // 2) If the framework is not-checkpointing: The slave is not removed
-      //    but the framework is removed from the slave's structs,
-      //    its tasks transitioned to LOST and resources recovered.
+      //
+      // 1) If the framework is checkpointing: No immediate action is
+      //    taken. The slave is given a chance to reconnect until the
+      //    slave observer times out (75s) and removes the slave.
+      //
+      // 2) If the framework is not-checkpointing: The slave is not
+      //    removed but the framework is removed from the slave's
+      //    structs, its tasks transitioned to LOST and resources
+      //    recovered.
+      //
+      // NOTE: If the framework hasn't re-registered since the master
+      // failed over, we assume the framework is checkpointing.
       hashset<FrameworkID> frameworkIds =
         slave->tasks.keys() | slave->executors.keys();
 
@@ -7822,7 +7828,7 @@ void Master::removeTask(Task* task)
 
   // Remove from framework.
   Framework* framework = getFramework(task->framework_id());
-  if (framework != nullptr) { // A framework might not be re-connected yet.
+  if (framework != nullptr) { // A framework might not be re-registered yet.
     framework->removeTask(task);
   }
 


[03/10] mesos git commit: Improved FaultToleranceTest.FrameworkReregister.

Posted by vi...@apache.org.
Improved FaultToleranceTest.FrameworkReregister.

Code cleanup; also check output of the "/state" endpoint.

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


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

Branch: refs/heads/master
Commit: 8030108b0dfcc72f5f79236806269bd202b6af14
Parents: 4b9dd04
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:05 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:05 2016 -0800

----------------------------------------------------------------------
 src/tests/fault_tolerance_tests.cpp | 53 +++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8030108b/src/tests/fault_tolerance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fault_tolerance_tests.cpp b/src/tests/fault_tolerance_tests.cpp
index 1a8888d..59f68f6 100644
--- a/src/tests/fault_tolerance_tests.cpp
+++ b/src/tests/fault_tolerance_tests.cpp
@@ -803,21 +803,20 @@ TEST_F(FaultToleranceTest, FrameworkReregister)
   MockScheduler sched;
   TestingMesosSchedulerDriver driver(&sched, &schedDetector);
 
-  Future<Nothing> registered;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureSatisfy(&registered));
+  EXPECT_CALL(sched, registered(&driver, _, _));
 
   Future<Nothing> resourceOffers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
     .WillOnce(FutureSatisfy(&resourceOffers));
 
-  Future<process::Message> message =
-    FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);
+  // Pause the clock so that we know the time at which framework
+  // (re-)registration should occur.
+  Clock::pause();
+
+  process::Time registerTime = Clock::now();
 
   driver.start();
 
-  AWAIT_READY(message); // Framework registered message, to get the pid.
-  AWAIT_READY(registered); // Framework registered call.
   AWAIT_READY(resourceOffers);
 
   Future<Nothing> disconnected;
@@ -830,28 +829,60 @@ TEST_F(FaultToleranceTest, FrameworkReregister)
 
   Future<Nothing> resourceOffers2;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
-    .WillOnce(FutureSatisfy(&resourceOffers2))
-    .WillRepeatedly(Return()); // Ignore subsequent offers.
+    .WillOnce(FutureSatisfy(&resourceOffers2));
 
   EXPECT_CALL(sched, offerRescinded(&driver, _))
     .Times(AtMost(1));
 
+  // Advance the clock so that the initial registration time and the
+  // re-registration time are distinct.
+  Clock::advance(Seconds(2));
+  process::Time reregisterTime = Clock::now();
+
   // Simulate a spurious leading master change at the scheduler.
   schedDetector.appoint(master.get()->pid);
 
   AWAIT_READY(disconnected);
-
   AWAIT_READY(reregistered);
 
   // Trigger the allocation and therefore resource offer instantly to
   // avoid blocking the test.
-  Clock::pause();
   Clock::advance(masterFlags.allocation_interval);
   Clock::resume();
 
   // The re-registered framework should get offers.
   AWAIT_READY(resourceOffers2);
 
+  // Check that the framework is displayed correctly in the "/state" endpoint.
+  Future<Response> response = process::http::get(
+      master.get()->pid,
+      "state",
+      None(),
+      createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
+
+  Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
+  ASSERT_SOME(parse);
+
+  JSON::Array frameworks = parse->values["frameworks"].as<JSON::Array>();
+
+  EXPECT_EQ(1u, frameworks.values.size());
+
+  JSON::Object framework = frameworks.values.front().as<JSON::Object>();
+
+  EXPECT_TRUE(framework.values["active"].as<JSON::Boolean>().value);
+
+  EXPECT_EQ(
+      static_cast<int64_t>(registerTime.secs()),
+      framework.values["registered_time"].as<JSON::Number>().as<int64_t>());
+
+  ASSERT_NE(0, framework.values.count("reregistered_time"));
+  EXPECT_EQ(
+      static_cast<int64_t>(reregisterTime.secs()),
+      framework.values["reregistered_time"].as<JSON::Number>().as<int64_t>());
+
   driver.stop();
   driver.join();
 }


[04/10] mesos git commit: Improved SlaveRecoveryTest.ReconcileShutdownFramework.

Posted by vi...@apache.org.
Improved SlaveRecoveryTest.ReconcileShutdownFramework.

Check the output of the "/state" endpoint to confirm that the framework
has been shutdown properly and the task has been marked as killed.

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


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

Branch: refs/heads/master
Commit: 4cc4fe42ecf9280f87104ea355003a09a6fde231
Parents: 8030108
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:09 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:09 2016 -0800

----------------------------------------------------------------------
 src/tests/slave_recovery_tests.cpp | 46 +++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4cc4fe42/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp
index 3b7d8cf..324cf59 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -34,6 +34,7 @@
 
 #include <process/dispatch.hpp>
 #include <process/gmock.hpp>
+#include <process/http.hpp>
 #include <process/owned.hpp>
 #include <process/reap.hpp>
 
@@ -73,6 +74,9 @@ using namespace mesos::internal::slave;
 
 using namespace process;
 
+using process::http::OK;
+using process::http::Response;
+
 using google::protobuf::RepeatedPtrField;
 
 using mesos::internal::master::Master;
@@ -3013,8 +3017,7 @@ TYPED_TEST(SlaveRecoveryTest, ReconcileShutdownFramework)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  // Capture the slave and framework ids.
-  SlaveID slaveId = offers.get()[0].slave_id();
+  // Capture the framework id.
   FrameworkID frameworkId = offers.get()[0].framework_id();
 
   // Expecting TASK_RUNNING status.
@@ -3061,6 +3064,45 @@ TYPED_TEST(SlaveRecoveryTest, ReconcileShutdownFramework)
 
   // Ensure that the executor is terminated.
   AWAIT_READY(executorTerminated);
+
+  // Check the output of the master's "/state" endpoint.
+  Future<Response> response = process::http::get(
+      master.get()->pid,
+      "state",
+      None(),
+      createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
+
+  Try<JSON::Object> parse = JSON::parse<JSON::Object>(response->body);
+  ASSERT_SOME(parse);
+
+  EXPECT_TRUE(parse->values["frameworks"].as<JSON::Array>().values.empty());
+  EXPECT_TRUE(parse->values["orphan_tasks"].as<JSON::Array>().values.empty());
+
+  JSON::Array completedFrameworks =
+    parse->values["completed_frameworks"].as<JSON::Array>();
+
+  ASSERT_EQ(1u, completedFrameworks.values.size());
+
+  JSON::Object completedFramework =
+    completedFrameworks.values.front().as<JSON::Object>();
+
+  EXPECT_EQ(
+      frameworkId,
+      completedFramework.values["id"].as<JSON::String>().value);
+
+  JSON::Array completedTasks =
+    completedFramework.values["completed_tasks"].as<JSON::Array>();
+
+  ASSERT_EQ(1u, completedTasks.values.size());
+
+  JSON::Object completedTask = completedTasks.values.front().as<JSON::Object>();
+
+  EXPECT_EQ(
+      "TASK_KILLED",
+      completedTask.values["state"].as<JSON::String>().value);
 }