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 2015/10/28 22:01:19 UTC

[1/3] mesos git commit: Removed redundant code for conversion from PID to HTTP based frameworks.

Repository: mesos
Updated Branches:
  refs/heads/master 3d67a9044 -> 8fe7997ac


Removed redundant code for conversion from PID to HTTP based
frameworks.

This conversion logic is redundant and is already being taken care of
as part of the `updateConnection` function.

https://github.com/apache/mesos/blob/master/src/master/master.hpp#L1736

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


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

Branch: refs/heads/master
Commit: 985b9d5083e9aeb0ee09772ed82f4ad0eda5f2cd
Parents: 3d67a90
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Wed Oct 28 13:59:02 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Oct 28 13:59:04 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/985b9d50/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 39ce9bc..72ce331 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2024,12 +2024,6 @@ void Master::_subscribe(
       LOG(INFO) << "Allowing framework " << *framework
                 << " to subscribe with an already used id";
 
-      // Convert the framework to an http framework if it was
-      // pid based in the past.
-      if (framework->pid.isSome()) {
-        framework->pid = None();
-      }
-
       framework->connected = true;
       framework->updateConnection(http);
 


[3/3] mesos git commit: Added test to verify downgrade from HTTP to PID based schedulers.

Posted by vi...@apache.org.
Added test to verify downgrade from HTTP to PID based schedulers.

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


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

Branch: refs/heads/master
Commit: 8fe7997ac8f737ccbf0242bbc3e0c3c902de6dc1
Parents: 6d3db49
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Wed Oct 28 14:00:35 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Oct 28 14:00:35 2015 -0700

----------------------------------------------------------------------
 src/tests/scheduler_http_api_tests.cpp | 76 +++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8fe7997a/src/tests/scheduler_http_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_http_api_tests.cpp b/src/tests/scheduler_http_api_tests.cpp
index d338a1b..b6f6e91 100644
--- a/src/tests/scheduler_http_api_tests.cpp
+++ b/src/tests/scheduler_http_api_tests.cpp
@@ -517,6 +517,82 @@ TEST_P(SchedulerHttpApiTest, UpdatePidToHttpScheduler)
 }
 
 
+// This test verifies that we are able to downgrade from a HTTP based
+// framework to PID.
+TEST_P(SchedulerHttpApiTest, UpdateHttpToPidScheduler)
+{
+  // HTTP schedulers cannot yet authenticate.
+  master::Flags flags = CreateMasterFlags();
+  flags.authenticate_frameworks = false;
+
+  Try<PID<Master>> master = StartMaster(flags);
+  ASSERT_SOME(master);
+
+  v1::FrameworkInfo frameworkInfo = DEFAULT_V1_FRAMEWORK_INFO;
+
+  Call call;
+  call.set_type(Call::SUBSCRIBE);
+
+  Call::Subscribe* subscribe = call.mutable_subscribe();
+  subscribe->mutable_framework_info()->CopyFrom(frameworkInfo);
+
+  // Retrieve the parameter passed as content type to this test.
+  const string contentType = GetParam();
+  process::http::Headers headers;
+  headers["Accept"] = contentType;
+
+  Future<Response> response = process::http::streaming::post(
+      master.get(),
+      "api/v1/scheduler",
+      headers,
+      serialize(call, contentType),
+      contentType);
+
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  EXPECT_SOME_EQ("chunked", response.get().headers.get("Transfer-Encoding"));
+  ASSERT_EQ(Response::PIPE, response.get().type);
+
+  Option<Pipe::Reader> reader = response.get().reader;
+  ASSERT_SOME(reader);
+
+  auto deserializer = lambda::bind(
+      &SchedulerHttpApiTest::deserialize, this, contentType, lambda::_1);
+
+  Reader<Event> responseDecoder(Decoder<Event>(deserializer), reader.get());
+
+  Future<Result<Event>> event = responseDecoder.read();
+  AWAIT_READY(event);
+  ASSERT_SOME(event.get());
+
+  // Check event type is subscribed and the framework id is set.
+  ASSERT_EQ(Event::SUBSCRIBED, event.get().get().type());
+  frameworkInfo.mutable_id()->
+    CopyFrom(event.get().get().subscribed().framework_id());
+
+  // Make sure it receives a heartbeat.
+  event = responseDecoder.read();
+  AWAIT_READY(event);
+  ASSERT_SOME(event.get());
+
+  ASSERT_EQ(Event::HEARTBEAT, event.get().get().type());
+
+  // Start PID based scheduler without credentials.
+  MockScheduler sched;
+  MesosSchedulerDriver driver(&sched, devolve(frameworkInfo), master.get());
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  driver.start();
+
+  AWAIT_READY(frameworkId);
+  ASSERT_EQ(evolve(frameworkId.get()), frameworkInfo.id());
+
+  Shutdown();
+}
+
+
 // This test verifies that updating a PID based framework to HTTP
 // framework fails when force is not set and the PID based
 // framework is already connected.


[2/3] mesos git commit: Added logic to ensure the during a HTTP to PID scheduler downgrade, the previous HTTP instance gets an error message.

Posted by vi...@apache.org.
Added logic to ensure the during a HTTP to PID scheduler downgrade, the
previous HTTP instance gets an error message.

Presently, when there is a downgrade from HTTP to PID based scheduler,
we did not use to send the previous HTTP scheduler instance an error
message. Modified the logic to send in an error message to the old HTTP
based instance.

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


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

Branch: refs/heads/master
Commit: 6d3db49bbec9fb84f350d009306bf83754f5a97f
Parents: 985b9d5
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Wed Oct 28 13:59:45 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Oct 28 13:59:47 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/6d3db49b/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 72ce331..9f4586e 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -5465,16 +5465,16 @@ void Master::failoverFramework(Framework* framework, const UPID& newPid)
   const Option<UPID> oldPid = framework->pid;
 
   // There are a few failover cases to consider:
-  //   1. The pid has changed. In this case we definitely want to
-  //      send a FrameworkErrorMessage to shut down the older
-  //      scheduler.
+  //   1. The pid has changed or it was previously a HTTP based scheduler.
+  //      In these cases we definitely want to send a FrameworkErrorMessage to
+  //      shut down the older scheduler.
   //   2. The pid has not changed.
   //      2.1 The old scheduler on that pid failed over to a new
   //          instance on the same pid. No need to shut down the old
   //          scheduler as it is necessarily dead.
   //      2.2 This is a duplicate message. In this case, the scheduler
   //          has not failed over, so we do not want to shut it down.
-  if (oldPid.isSome() && oldPid != newPid) {
+  if (oldPid != newPid && framework->connected) {
     FrameworkErrorMessage message;
     message.set_message("Framework failed over");
     framework->send(message);