fix exception in Supervisor.start causing overlord unable to become leader (#6516)

* fix exception thrown by Supervisor.start causing overlord unable to become leader

* fix style
This commit is contained in:
Clint Wylie 2018-10-25 15:44:04 -07:00 committed by Gian Merlino
parent aef1b39762
commit ee1fc93f97
2 changed files with 26 additions and 1 deletions

View File

@ -133,7 +133,12 @@ public class SupervisorManager
for (String id : supervisors.keySet()) {
SupervisorSpec spec = supervisors.get(id);
if (!(spec instanceof NoopSupervisorSpec)) {
createAndStartSupervisorInternal(spec, false);
try {
createAndStartSupervisorInternal(spec, false);
}
catch (Exception ex) {
log.error(ex, "Failed to start supervisor: [%s]", spec.getId());
}
}
}

View File

@ -228,6 +228,26 @@ public class SupervisorManagerTest extends EasyMockSupport
manager.start();
}
@Test
public void testStartIndividualSupervisorsFailStart()
{
Map<String, SupervisorSpec> existingSpecs = ImmutableMap.of(
"id1", new TestSupervisorSpec("id1", supervisor1),
"id3", new TestSupervisorSpec("id3", supervisor3)
);
EasyMock.expect(metadataSupervisorManager.getLatest()).andReturn(existingSpecs);
supervisor3.start();
supervisor1.start();
EasyMock.expectLastCall().andThrow(new RuntimeException("supervisor explosion"));
replayAll();
manager.start();
// if we get here, we are properly insulated from exploding supervisors
}
@Test
public void testStopThrowsException()
{