use of bio.terra.stairway.exception.FlightWaitTimedOutException in project terra-workspace-manager by DataBiosphere.
the class AwaitWorkspaceCreateFlightStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
FlightUtils.validateRequiredEntries(context.getWorkingMap(), ControlledResourceKeys.WORKSPACE_CREATE_FLIGHT_ID);
final var workspaceCreateJobId = context.getWorkingMap().get(ControlledResourceKeys.WORKSPACE_CREATE_FLIGHT_ID, String.class);
try {
final FlightState flightState = context.getStairway().waitForFlight(workspaceCreateJobId, FlightUtils.FLIGHT_POLL_SECONDS, FlightUtils.FLIGHT_POLL_CYCLES);
if (FlightStatus.SUCCESS != flightState.getFlightStatus()) {
// retrying this step won't help if the flight already failed
return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, flightState.getException().orElseGet(() -> new RuntimeException("No exception found for subflight.")));
}
} catch (DatabaseOperationException | FlightWaitTimedOutException e) {
// Retry for database issues or expired wait loop
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
}
return StepResult.getStepResultSuccess();
}
Aggregations