Skip to content

Commit

Permalink
prevent pending deploys from being created without corresponding save…
Browse files Browse the repository at this point in the history
…d deploy
  • Loading branch information
William Hou committed Nov 9, 2021
1 parent 22e0dea commit 78249b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public void processResult(CuratorFramework client, CuratorEvent event)
if (cache.isPresent()) {
cache.get().set(event.getPath(), object);
}
} catch (Exception e) {
LOG.error("Exception processing curator result", e);
} finally {
latch.countDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ public SingularityDeployKey apply(SingularityDeploy input) {
return deployKeyToDeploy;
}

public SingularityCreateResult saveDeploy(
public SingularityCreateResult createDeployIfNotExists(
SingularityRequest request,
SingularityDeployMarker deployMarker,
SingularityDeploy deploy
) {
final SingularityCreateResult deploySaveResult = create(
SingularityCreateResult deploySaveResult = create(
getDeployDataPath(deploy.getRequestId(), deploy.getId()),
deploy,
deployTranscoder
Expand All @@ -294,7 +294,15 @@ public SingularityCreateResult saveDeploy(
deployMarker
);
}
return deploySaveResult;
}

public SingularityCreateResult saveDeploy(
SingularityRequest request,
SingularityDeployMarker deployMarker,
SingularityDeploy deploy
) {
createDeployIfNotExists(request, deployMarker, deploy);
LOG.info("Creating deploy {}", deployMarker);

singularityEventListener.deployHistoryEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ public SingularityRequestParent deploy(
// This can cause a conflict if run outside the lock, causing the pending deploy to be checked before deploy data is saved
schedulerLock.runWithRequestLock(
() -> {
deployManager.createDeployIfNotExists(
updatedRequest,
deployMarker,
validatedDeploy
);
deployAlreadyInProgress.set(
deployManager.createPendingDeploy(pendingDeployObj) ==
SingularityCreateResult.EXISTED
Expand Down

0 comments on commit 78249b3

Please sign in to comment.