Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Fix flyte error translation (#1085)
Browse files Browse the repository at this point in the history
* fix(FlyteEventTranslator): clean error codes

Clean error codes in the flyte event translator to replace the RetriesExhaused| prefix that comes with all dynamic node failures and retriable nodes

* test(FlyteEventTranslator): add cleaning tests

Add tests to ensure that error codes with the retries exhaused prefix are matching the expected error code

* Fix typo

---------

Co-authored-by: Brandon Segal <brandonsegal.k@gmail.com>
  • Loading branch information
andresgomezfrr and brandon-segal authored Jun 2, 2023
1 parent 2d0ad8c commit 30b7554
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

public class FlyteEventTranslator {
private static final Logger LOG = LoggerFactory.getLogger(FlyteEventTranslator.class);

private static final String RETRIES_EXHAUSTED = "RetriesExhausted|";
private static final String PERSISTED_CODE = "USER:Persisted";
private static final String NOT_RETRYABLE_CODE = "USER:NotRetryable";
private static final String NOT_READY_CODE = "USER:NotReady";
Expand Down Expand Up @@ -96,7 +96,7 @@ static private List<Event> handleExited(ExecutionOuterClass.Execution execution,
case FAILED:
case ABORTED:
case TIMED_OUT:
final String flyteCode = execution.getClosure().getError().getCode();
final String flyteCode = execution.getClosure().getError().getCode().replace(RETRIES_EXHAUSTED,"");
final int styxCode = KNOWN_ERROR_CODES.getOrDefault(flyteCode, UNKNOWN_ERROR_EXIT_CODE);
LOG.info("Issue 'terminate' event for: " + runState.workflowInstance());
generatedEvents.add(Event.terminate(runState.workflowInstance(), Optional.of(styxCode)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ private Object[] parametersForTestTransitionPollingToTerminateExitCodes() {
new Object[] { Execution.WorkflowExecution.Phase.FAILED, "USER:AnythingElse", UNKNOWN_ERROR_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.ABORTED, "USER:AnythingElse", UNKNOWN_ERROR_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.TIMED_OUT, "USER:AnythingElse", UNKNOWN_ERROR_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.FAILED, "RetriesExhausted|USER:NotReady", MISSING_DEPS_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.FAILED, "RetriesExhausted|USER:NotReady", MISSING_DEPS_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.ABORTED, "RetriesExhausted|USER:NotReady", MISSING_DEPS_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.TIMED_OUT, "RetriesExhausted|USER:NotReady", MISSING_DEPS_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.FAILED, "RetriesExhausted|USER:NotRetryable", UNRECOVERABLE_FAILURE_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.ABORTED, "RetriesExhausted|USER:NotRetryable", UNRECOVERABLE_FAILURE_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.TIMED_OUT, "RetriesExhausted|USER:NotRetryable", UNRECOVERABLE_FAILURE_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.FAILED, "RetriesExhausted|USER:Persisted", SUCCESS_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.ABORTED, "RetriesExhausted|USER:Persisted", SUCCESS_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.TIMED_OUT, "RetriesExhausted|USER:Persisted", SUCCESS_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.FAILED, "RetriesExhausted|USER:AnythingElse", UNKNOWN_ERROR_EXIT_CODE },
new Object[] { Execution.WorkflowExecution.Phase.ABORTED, "RetriesExhausted|USER:AnythingElse", UNKNOWN_ERROR_EXIT_CODE},
new Object[] { Execution.WorkflowExecution.Phase.TIMED_OUT, "RetriesExhausted|USER:AnythingElse", UNKNOWN_ERROR_EXIT_CODE},
};
}

Expand Down

0 comments on commit 30b7554

Please sign in to comment.