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 2017/12/04 21:13:03 UTC

mesos git commit: Fixed an issue with the scheduler driver subscribe backoff time.

Repository: mesos
Updated Branches:
  refs/heads/master 6a98530a5 -> 3caca9716


Fixed an issue with the scheduler driver subscribe backoff time.

When framework failover time is set to zero (which is the
default value), the scheduler driver subscribe backoff time
will also become zero. Ignore failover time if it is zero
when deciding the subscribe backoff time.
Also added a dedicated test.

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


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

Branch: refs/heads/master
Commit: 3caca9716314bba6d87c9e5a8654f4d09fbaf9c2
Parents: 6a98530
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Mon Dec 4 13:12:23 2017 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Dec 4 13:12:23 2017 -0800

----------------------------------------------------------------------
 src/sched/sched.cpp                  |  2 +-
 src/tests/scheduler_driver_tests.cpp | 47 +++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3caca971/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index 6028499..72bd413 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -844,7 +844,7 @@ protected:
     // by 1/10th of the failover timeout.
     if (framework.has_failover_timeout()) {
       Try<Duration> duration = Duration::create(framework.failover_timeout());
-      if (duration.isSome()) {
+      if (duration.isSome() && duration.get() > Duration::zero()) {
         maxBackoff = std::min(maxBackoff, duration.get() / 10);
       }
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/3caca971/src/tests/scheduler_driver_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_driver_tests.cpp b/src/tests/scheduler_driver_tests.cpp
index 14d872b..46af8d2 100644
--- a/src/tests/scheduler_driver_tests.cpp
+++ b/src/tests/scheduler_driver_tests.cpp
@@ -68,6 +68,7 @@ using testing::_;
 using testing::AtMost;
 using testing::DoAll;
 using testing::Return;
+using ::testing::InSequence;
 
 namespace mesos {
 namespace internal {
@@ -76,6 +77,52 @@ namespace tests {
 class MesosSchedulerDriverTest : public MesosTest {};
 
 
+// Ensures that the scheduler driver can backoff correctly when
+// framework failover time is set to zero.
+TEST_F(MesosSchedulerDriverTest, RegistrationWithZeroFailoverTime)
+{
+  Try<Owned<cluster::Master>> master = StartMaster();
+  ASSERT_SOME(master);
+
+  FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
+  frameworkInfo.set_failover_timeout(0);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, frameworkInfo, master.get()->pid, DEFAULT_CREDENTIAL);
+
+  Clock::pause();
+
+  {
+    InSequence inSequence;
+
+    // Drop the first SUBSCRIBE call so that the driver retries.
+    DROP_CALL(
+        mesos::scheduler::Call(),
+        mesos::scheduler::Call::SUBSCRIBE,
+        _,
+        master.get()->pid);
+
+    // Settling the clock ensures that if a retried SUBSCRIBE
+    // call is enqueued it will be processed. Since the backoff
+    // is non-zero no new SUBSCRIBE call should be sent when
+    // the clock is paused.
+    EXPECT_NO_FUTURE_CALLS(
+        mesos::scheduler::Call(),
+        mesos::scheduler::Call::SUBSCRIBE,
+        _,
+        master.get()->pid);
+  }
+
+  driver.start();
+
+  Clock::settle();
+
+  driver.stop();
+  driver.join();
+}
+
+
 TEST_F(MesosSchedulerDriverTest, MetricsEndpoint)
 {
   Try<Owned<cluster::Master>> master = StartMaster();