Search in sources :

Example 1 with CollectMetadataResultToUpscaleFailureEventConverter

use of com.sequenceiq.freeipa.flow.freeipa.upscale.failure.CollectMetadataResultToUpscaleFailureEventConverter in project cloudbreak by hortonworks.

the class FreeIpaUpscaleActions method upscaleFailureAction.

@Bean(name = "UPSCALE_FAIL_STATE")
public Action<?, ?> upscaleFailureAction() {
    return new AbstractUpscaleAction<>(UpscaleFailureEvent.class) {

        @Inject
        private OperationService operationService;

        @Override
        protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<UpscaleState, UpscaleFlowEvent> stateContext, UpscaleFailureEvent payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            flow.setFlowFailed(payload.getException());
            return super.createFlowContext(flowParameters, stateContext, payload);
        }

        @Override
        protected void doExecute(StackContext context, UpscaleFailureEvent payload, Map<Object, Object> variables) {
            LOGGER.error("Upscale failed with payload: " + payload);
            Stack stack = context.getStack();
            String environmentCrn = stack.getEnvironmentCrn();
            SuccessDetails successDetails = new SuccessDetails(environmentCrn);
            successDetails.getAdditionalDetails().put(payload.getFailedPhase(), payload.getSuccess() == null ? List.of() : new ArrayList<>(payload.getSuccess()));
            String message = "Upscale failed during " + payload.getFailedPhase();
            FailureDetails failureDetails = new FailureDetails(environmentCrn, message);
            if (payload.getFailureDetails() != null) {
                failureDetails.getAdditionalDetails().putAll(payload.getFailureDetails());
            }
            String errorReason = getErrorReason(payload.getException());
            stackUpdater.updateStackStatus(context.getStack().getId(), getFailedStatus(variables), errorReason);
            operationService.failOperation(stack.getAccountId(), getOperationId(variables), message, List.of(successDetails), List.of(failureDetails));
            enableStatusChecker(stack, "Failed upscaling FreeIPA");
            enableNodeStatusChecker(stack, "Failed upscaling FreeIPA");
            sendEvent(context, FAIL_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected void initPayloadConverterMap(List<PayloadConverter<UpscaleFailureEvent>> payloadConverters) {
            payloadConverters.add(new UpscaleStackResultToUpscaleFailureEventConverter());
            payloadConverters.add(new CollectMetadataResultToUpscaleFailureEventConverter());
            payloadConverters.add(new BootstrapMachinesFailedToUpscaleFailureEventConverter());
            payloadConverters.add(new HostMetadataSetupFailedToUpscaleFailureEventConverter());
            payloadConverters.add(new InstallFreeIpaServicesFailedToUpscaleFailureEventConverter());
            payloadConverters.add(new ClusterProxyUpdateRegistrationFailedToUpscaleFailureEventConverter());
            payloadConverters.add(new PostInstallFreeIpaFailedToUpscaleFailureEventConverter());
        }
    };
}
Also used : SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) ClusterProxyUpdateRegistrationFailedToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.ClusterProxyUpdateRegistrationFailedToUpscaleFailureEventConverter) StateContext(org.springframework.statemachine.StateContext) ArrayList(java.util.ArrayList) PostInstallFreeIpaFailedToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.PostInstallFreeIpaFailedToUpscaleFailureEventConverter) BootstrapMachinesFailedToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.BootstrapMachinesFailedToUpscaleFailureEventConverter) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) Flow(com.sequenceiq.flow.core.Flow) Stack(com.sequenceiq.freeipa.entity.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) HostMetadataSetupFailedToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.HostMetadataSetupFailedToUpscaleFailureEventConverter) FlowParameters(com.sequenceiq.flow.core.FlowParameters) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) UpscaleStackResultToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.UpscaleStackResultToUpscaleFailureEventConverter) UpscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent) ArrayList(java.util.ArrayList) List(java.util.List) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) InstallFreeIpaServicesFailedToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.InstallFreeIpaServicesFailedToUpscaleFailureEventConverter) Map(java.util.Map) CollectMetadataResultToUpscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.upscale.failure.CollectMetadataResultToUpscaleFailureEventConverter) Bean(org.springframework.context.annotation.Bean)

Aggregations

CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 UpscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent)1 BootstrapMachinesFailedToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.BootstrapMachinesFailedToUpscaleFailureEventConverter)1 ClusterProxyUpdateRegistrationFailedToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.ClusterProxyUpdateRegistrationFailedToUpscaleFailureEventConverter)1 CollectMetadataResultToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.CollectMetadataResultToUpscaleFailureEventConverter)1 HostMetadataSetupFailedToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.HostMetadataSetupFailedToUpscaleFailureEventConverter)1 InstallFreeIpaServicesFailedToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.InstallFreeIpaServicesFailedToUpscaleFailureEventConverter)1 PostInstallFreeIpaFailedToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.PostInstallFreeIpaFailedToUpscaleFailureEventConverter)1 UpscaleStackResultToUpscaleFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.upscale.failure.UpscaleStackResultToUpscaleFailureEventConverter)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1