From 281c0aaee5039248bc56d0c6711e45e141ae4c5d Mon Sep 17 00:00:00 2001 From: Abhishek Verma Date: Thu, 30 Mar 2017 14:36:00 -0700 Subject: [PATCH] Crash the scheduler if the scheduler driver receives an error, because it is already aborted Summary: See T797261 for the rationale. Reviewers: varung, zhitao, karthik, zmanji Reviewed By: zhitao, zmanji Subscribers: jenkins, zmanji, #cassandraservice Differential Revision: https://code.uberinternal.com/D801463 --- .../dcos/cassandra/scheduler/CassandraScheduler.java | 2 ++ .../dcos/cassandra/scheduler/CassandraSchedulerTest.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/cassandra-scheduler/src/main/java/com/mesosphere/dcos/cassandra/scheduler/CassandraScheduler.java b/cassandra-scheduler/src/main/java/com/mesosphere/dcos/cassandra/scheduler/CassandraScheduler.java index ae6189c6..8009f174 100644 --- a/cassandra-scheduler/src/main/java/com/mesosphere/dcos/cassandra/scheduler/CassandraScheduler.java +++ b/cassandra-scheduler/src/main/java/com/mesosphere/dcos/cassandra/scheduler/CassandraScheduler.java @@ -341,6 +341,8 @@ public void executorLost(SchedulerDriver driver, @Override public void error(SchedulerDriver driver, String message) { LOGGER.error("Scheduler driver error: {}", message); + // At this point the scheduler driver is already aborted, so there is no point staying alive. + throw new RuntimeException("Scheduler driver has been aborted because of error: " + message); } private List filterAcceptedOffers(List offers, diff --git a/cassandra-scheduler/src/test/java/com/mesosphere/dcos/cassandra/scheduler/CassandraSchedulerTest.java b/cassandra-scheduler/src/test/java/com/mesosphere/dcos/cassandra/scheduler/CassandraSchedulerTest.java index 279d3543..562ee403 100644 --- a/cassandra-scheduler/src/test/java/com/mesosphere/dcos/cassandra/scheduler/CassandraSchedulerTest.java +++ b/cassandra-scheduler/src/test/java/com/mesosphere/dcos/cassandra/scheduler/CassandraSchedulerTest.java @@ -322,6 +322,13 @@ public void testMultipleRegister() throws Exception { update(); } + @Test(expected = RuntimeException.class) + // Test that the scheduler throws a RuntimeException if the scheduler driver sends an error. + public void testSchedulerDriverError() throws Exception { + install(); + scheduler.error(driver, "scheduler driver error"); + } + private void update() { scheduler.registered(driver, frameworkId, Protos.MasterInfo.getDefaultInstance()); runReconcile(driver);