Search in sources :

Example 6 with FlightWaitTimedOutException

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();
}
Also used : FlightState(bio.terra.stairway.FlightState) DatabaseOperationException(bio.terra.stairway.exception.DatabaseOperationException) StepResult(bio.terra.stairway.StepResult) FlightWaitTimedOutException(bio.terra.stairway.exception.FlightWaitTimedOutException)

Aggregations

FlightState (bio.terra.stairway.FlightState)6 StepResult (bio.terra.stairway.StepResult)6 DatabaseOperationException (bio.terra.stairway.exception.DatabaseOperationException)6 FlightWaitTimedOutException (bio.terra.stairway.exception.FlightWaitTimedOutException)6 FlightMap (bio.terra.stairway.FlightMap)4 Map (java.util.Map)4 WsmCloneResourceResult (bio.terra.workspace.service.workspace.model.WsmCloneResourceResult)3 WsmResourceCloneDetails (bio.terra.workspace.service.workspace.model.WsmResourceCloneDetails)3 HashMap (java.util.HashMap)3 FlightStatus (bio.terra.stairway.FlightStatus)1 ApiClonedControlledGcpBigQueryDataset (bio.terra.workspace.generated.model.ApiClonedControlledGcpBigQueryDataset)1 ApiClonedWorkspace (bio.terra.workspace.generated.model.ApiClonedWorkspace)1 ApiCreatedControlledGcpGcsBucket (bio.terra.workspace.generated.model.ApiCreatedControlledGcpGcsBucket)1 ApiResourceCloneDetails (bio.terra.workspace.generated.model.ApiResourceCloneDetails)1 ApiResourceMetadata (bio.terra.workspace.generated.model.ApiResourceMetadata)1