mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(stepfunctions): fail a .sync Task on its child with States.TaskFailed and the child's description (#4675)
* fix(stepfunctions): fail a .sync Task on its child with States.TaskFailed and the child's description Measured on AWS (ap-northeast-1, 2026-09-29), six child endings under both states:startExecution.sync and .sync:2: FAILED with a custom error with and without a cause, FAILED with States.Timeout from a Task's own TimeoutSeconds, FAILED with States.TaskFailed, TIMED_OUT, and ABORTED by a StopExecution carrying an error and a cause. In every case the parent Task fails with States.TaskFailed, and the cause is the child's DescribeExecution response as JSON: PascalCase, keys in alphabetical order, Cause and Error only when the child has them, dates in epoch milliseconds, no Output. Floci passed the child's own error and cause straight through, falling back to States.TaskFailed and "Nested execution ended with status: X" only when the child had none. The error name matched AWS in two of the six cases and the cause in none, so a parent Catch on States.TaskFailed missed a child that failed with its own error or timed out, and a Catch on the child's error name fired where AWS never takes it. Closes #4562 * fix(stepfunctions): read a nested child's terminal state consistently, and keep its alias and version Review of #4675. The poll read the child's status without the monitor its worker and StopExecution write the terminal fields under (status last), so a terminal status could be seen before the error, cause or stop date behind it, and the cause built from a half-written child. The status is now read under that monitor, which makes everything written before it visible. A child started through an alias or a version also carries StateMachineAliasArn and StateMachineVersionArn in the cause, measured on AWS (ap-northeast-1, 2026-09-29): an alias gives both, a version only the version, each in its alphabetical place between StartDate and Status. --------- Co-authored-by: mitsukado-shinagawa <mitsukado-shinagawa@users.noreply.github.com>
This commit is contained in:
1 parent
dc3beadf6a
commit
7ff6a7cfa7
4 files changed
+524
-5
No files matched your search
@@ -1736,7 +1736,13 @@ public class AslExecutor {
|
||||
}
|
||||
io.github.hectorvent.floci.services.stepfunctions.model.Execution current =
|
||||
sfnService.get().describeExecution(execArn);
|
||||
String status = current.getStatus();
|
||||
String status;
|
||||
// The child's worker and StopExecution write its terminal fields under this monitor,
|
||||
// status last. Reading the status under it makes everything written before it visible,
|
||||
// so a terminal status is never seen without the error, cause and stop date behind it.
|
||||
synchronized (current) {
|
||||
status = current.getStatus();
|
||||
}
|
||||
if ("RUNNING".equals(status)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1763,13 +1769,50 @@ public class AslExecutor {
|
||||
}
|
||||
return envelope;
|
||||
}
|
||||
throw new FailStateException(
|
||||
current.getError() != null ? current.getError() : "States.TaskFailed",
|
||||
current.getCause() != null ? current.getCause()
|
||||
: "Nested execution ended with status: " + status);
|
||||
// However the child ended, FAILED, TIMED_OUT or ABORTED, and whatever its own error, the
|
||||
// parent sees States.TaskFailed (measured), so a Catch on the child's error never fires.
|
||||
throw new FailStateException("States.TaskFailed", nestedExecutionFailureCause(current));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The cause of a {@code .sync} Task whose child ended other than SUCCEEDED, as measured on AWS
|
||||
* for {@code .sync} and {@code .sync:2} alike: the child's DescribeExecution response in
|
||||
* PascalCase with its keys in alphabetical order, {@code Cause} and {@code Error} only when the
|
||||
* child has them, {@code StateMachineAliasArn} and {@code StateMachineVersionArn} only when it
|
||||
* was started through an alias or a version (an alias carries both), dates in epoch
|
||||
* milliseconds, and no {@code Output}. Floci does not implement
|
||||
* redrive, so the two redrive fields carry what AWS reports for a child never redriven.
|
||||
*/
|
||||
private String nestedExecutionFailureCause(Execution child) {
|
||||
ObjectNode cause = objectMapper.createObjectNode();
|
||||
if (child.getCause() != null) {
|
||||
cause.put("Cause", child.getCause());
|
||||
}
|
||||
if (child.getError() != null) {
|
||||
cause.put("Error", child.getError());
|
||||
}
|
||||
cause.put("ExecutionArn", child.getExecutionArn());
|
||||
cause.put("Input", child.getInput() != null ? child.getInput() : "{}");
|
||||
cause.putObject("InputDetails").put("Included", true);
|
||||
cause.put("Name", child.getName());
|
||||
cause.put("RedriveCount", 0);
|
||||
cause.put("RedriveStatus", "REDRIVABLE");
|
||||
cause.put("StartDate", Math.round(child.getStartDate() * 1000));
|
||||
if (child.getStateMachineAliasArn() != null) {
|
||||
cause.put("StateMachineAliasArn", child.getStateMachineAliasArn());
|
||||
}
|
||||
cause.put("StateMachineArn", child.getStateMachineArn());
|
||||
if (child.getStateMachineVersionArn() != null) {
|
||||
cause.put("StateMachineVersionArn", child.getStateMachineVersionArn());
|
||||
}
|
||||
cause.put("Status", child.getStatus());
|
||||
if (child.getStopDate() != null) {
|
||||
cause.put("StopDate", Math.round(child.getStopDate() * 1000));
|
||||
}
|
||||
return cause.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimized ECS RunTask integration. Step Functions passes PascalCase parameters
|
||||
* ({@code Cluster}, {@code TaskDefinition}, {@code Overrides.ContainerOverrides}, …)
|
||||
|
||||
Reference in new issue
Block a user