mirror of
https://github.com/floci-io/floci.git
synced 2026-12-04 18:48:00 -05:00
fix(codepipeline): serialize failure writes with stop publication (#8073)
Take the execution monitor when an action, stage or condition records a failure. A concurrent stop can no longer replace a Failed write between its terminal check and its Stopping transition. Port the remaining failure transitions and regression coverage from AndreKurait/floci#710. The stop handler already landed in upstream #7939. Hold the execution monitor across the approval completion check, result updates and persistence so stop cannot interleave with a rejected result. Share the held-monitor stop helper and cover rejection before a waiting stop. Wait for approval polling after token persistence in the existing stop-completion fixture. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> Co-authored-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
1 parent
2e97c50ca8
commit
589e1e58b4
2 files changed
+232
-37
No files matched your search
@@ -861,22 +861,24 @@ public class CodePipelineService {
|
||||
throw new AwsException("InvalidApprovalTokenException", "Approval token is invalid", 400);
|
||||
}
|
||||
|
||||
if (!"InProgress".equals(approval.getStatus())) {
|
||||
throw new AwsException("ApprovalAlreadyCompletedException",
|
||||
"The approval action has already been approved or rejected.", 400);
|
||||
}
|
||||
synchronized (execution) {
|
||||
if (!"InProgress".equals(approval.getStatus())) {
|
||||
throw new AwsException("ApprovalAlreadyCompletedException",
|
||||
"The approval action has already been approved or rejected.", 400);
|
||||
}
|
||||
|
||||
boolean approved = "Approved".equals(status);
|
||||
approval.setStatus(approved ? "Succeeded" : "Failed");
|
||||
approval.setSummary(summary);
|
||||
approval.setLastUpdateTime(now());
|
||||
if (!approved) {
|
||||
execution.setStatus("Failed");
|
||||
execution.setStatusSummary("Action " + actionName + " failed: " + summary);
|
||||
execution.getStageExecutionStatuses().put(stageName, "Failed");
|
||||
execution.setLastUpdateTime(now());
|
||||
boolean approved = "Approved".equals(status);
|
||||
approval.setStatus(approved ? "Succeeded" : "Failed");
|
||||
approval.setSummary(summary);
|
||||
approval.setLastUpdateTime(now());
|
||||
if (!approved) {
|
||||
execution.setStatus("Failed");
|
||||
execution.setStatusSummary("Action " + actionName + " failed: " + summary);
|
||||
execution.getStageExecutionStatuses().put(stageName, "Failed");
|
||||
execution.setLastUpdateTime(now());
|
||||
}
|
||||
putExecution(execution);
|
||||
}
|
||||
putExecution(execution);
|
||||
return mapper.createObjectNode().put("approvedAt", now());
|
||||
}
|
||||
|
||||
@@ -1884,10 +1886,12 @@ public class CodePipelineService {
|
||||
}
|
||||
|
||||
private void failForCondition(CodePipelineExecution execution, String stageName, String conditionType) {
|
||||
execution.setStatus("Failed");
|
||||
execution.setStatusSummary(
|
||||
"Condition " + conditionType + " failed in stage " + stageName + ".");
|
||||
putExecution(execution);
|
||||
synchronized (execution) {
|
||||
execution.setStatus("Failed");
|
||||
execution.setStatusSummary(
|
||||
"Condition " + conditionType + " failed in stage " + stageName + ".");
|
||||
putExecution(execution);
|
||||
}
|
||||
}
|
||||
|
||||
private void finishExecutionRun(CodePipelineExecution execution) {
|
||||
@@ -1984,7 +1988,9 @@ public class CodePipelineService {
|
||||
.toList();
|
||||
CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join();
|
||||
if (futures.stream().anyMatch(CompletableFuture::isCompletedExceptionally)) {
|
||||
execution.setStatus("Failed");
|
||||
synchronized (execution) {
|
||||
execution.setStatus("Failed");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2029,8 +2035,10 @@ public class CodePipelineService {
|
||||
state.setErrorDetails(Map.of(
|
||||
"code", e instanceof AwsException aws ? aws.getErrorCode() : "ActionExecutionFailed",
|
||||
"message", Objects.toString(e.getMessage(), "Action failed")));
|
||||
execution.setStatus("Failed");
|
||||
execution.setStatusSummary("Action " + state.getActionName() + " failed: " + state.getSummary());
|
||||
synchronized (execution) {
|
||||
execution.setStatus("Failed");
|
||||
execution.setStatusSummary("Action " + state.getActionName() + " failed: " + state.getSummary());
|
||||
}
|
||||
} finally {
|
||||
state.setLastUpdateTime(now());
|
||||
putExecution(execution);
|
||||
|
||||
Reference in new issue
Block a user