From 22e0dea74bc3a1c89066c7e77f4384d5b89856a0 Mon Sep 17 00:00:00 2001 From: William Hou Date: Fri, 5 Nov 2021 13:23:25 -0400 Subject: [PATCH] prevent pending request deletion of new scheduled task deploy on startup with outdated running task --- .../scheduler/SingularityScheduler.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityScheduler.java b/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityScheduler.java index 453ccf4554..8113f724ae 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityScheduler.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityScheduler.java @@ -491,12 +491,25 @@ private void handlePendingRequestsForDeployKey( pendingRequest, maybePendingDeploy ); - if ( - missingInstances == 0 && - !matchingTaskIds.isEmpty() && - updatedRequest.isScheduled() && - pendingRequest.getPendingType() == PendingType.NEW_DEPLOY - ) { + boolean scheduledRequestWithActiveTask = + ( + missingInstances == 0 && + !matchingTaskIds.isEmpty() && + updatedRequest.isScheduled() && + pendingRequest.getPendingType() == PendingType.NEW_DEPLOY + ); + boolean scheduledRequestWithOutdatedActiveTask = + ( + missingInstances == 0 && + matchingTaskIds.isEmpty() && + updatedRequest.isScheduled() && + ( + pendingRequest.getPendingType() == PendingType.NEW_DEPLOY || + pendingRequest.getPendingType() == PendingType.STARTUP + ) + ); + + if (scheduledRequestWithActiveTask || scheduledRequestWithOutdatedActiveTask) { LOG.trace( "Holding pending request {} because it is scheduled and has an active task", pendingRequest