diff --git a/SingularityService/src/main/java/com/hubspot/singularity/mesos/SingularityStartup.java b/SingularityService/src/main/java/com/hubspot/singularity/mesos/SingularityStartup.java index 1560984bb8..bef94d8d29 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/mesos/SingularityStartup.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/mesos/SingularityStartup.java @@ -18,6 +18,7 @@ import com.hubspot.mesos.MesosUtils; import com.hubspot.mesos.client.MesosClient; import com.hubspot.mesos.json.MesosMasterStateObject; +import com.hubspot.singularity.RequestType; import com.hubspot.singularity.SingularityDeployKey; import com.hubspot.singularity.SingularityPendingDeploy; import com.hubspot.singularity.SingularityPendingRequest; @@ -135,8 +136,8 @@ void checkSchedulerForInconsistentState() { private void checkActiveRequest(SingularityRequestWithState requestWithState, Map deployKeyToPendingTaskId, final long timestamp) { final SingularityRequest request = requestWithState.getRequest(); - if (request.isOneOff()) { - return; + if (request.getRequestType() == RequestType.ON_DEMAND || request.getRequestType() == RequestType.RUN_ONCE) { + return; // There's no situation where we'd want to schedule an On Demand or Run Once request at startup, so don't even bother with them. } Optional requestDeployState = deployManager.getRequestDeployState(request.getId()); diff --git a/SingularityService/src/test/java/com/hubspot/singularity/mesos/SingularityStartupTest.java b/SingularityService/src/test/java/com/hubspot/singularity/mesos/SingularityStartupTest.java index 4577a308a0..1c4979a829 100644 --- a/SingularityService/src/test/java/com/hubspot/singularity/mesos/SingularityStartupTest.java +++ b/SingularityService/src/test/java/com/hubspot/singularity/mesos/SingularityStartupTest.java @@ -122,7 +122,7 @@ public void testScheduledTasksDontGetRescheduledDuringRun() { } @Test - public void testOneOffDoesntGetRescheduled() { + public void testOnDemandDoesntGetRescheduled() { saveRequest(new SingularityRequestBuilder(requestId, RequestType.ON_DEMAND).build()); deploy(firstDeployId); deployChecker.checkDeploys(); @@ -142,4 +142,21 @@ public void testOneOffDoesntGetRescheduled() { Assert.assertTrue(requestManager.getPendingRequests().get(0).getPendingType() == PendingType.ONEOFF); } + @Test + public void testRunOnceDoesntGetRescheduled() { + saveRequest(new SingularityRequestBuilder(requestId, RequestType.RUN_ONCE).build()); + deploy(firstDeployId); + deployChecker.checkDeploys(); + + scheduler.drainPendingQueue(stateCacheProvider.get()); + resourceOffers(); + + Assert.assertTrue(requestManager.getPendingRequests().isEmpty()); + Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty()); + + startup.checkSchedulerForInconsistentState(); + + // assert that SingularityStartup does not enqueue a SingularityPendingRequest (pendingType=STARTUP) for the RUN_ONCE request + Assert.assertTrue(requestManager.getPendingRequests().isEmpty()); + } }