Search in sources :

Example 6 with DownscaleFailureEvent

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.

the class DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter method convert.

@Override
public DownscaleFailureEvent convert(Object payload) {
    DownscaleStackCollectResourcesResult downscaleStackCollectResourcesResult = (DownscaleStackCollectResourcesResult) payload;
    DownscaleFailureEvent event = new DownscaleFailureEvent(downscaleStackCollectResourcesResult.getResourceId(), "Collecting resources", Set.of(), Map.of(), new Exception("Payload failed: " + payload));
    return event;
}
Also used : DownscaleStackCollectResourcesResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)

Example 7 with DownscaleFailureEvent

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method updateEnvironmentStackConfigAction.

@Bean(name = "DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_STATE")
public Action<?, ?> updateEnvironmentStackConfigAction() {
    return new AbstractDownscaleAction<>(StackEvent.class) {

        @Inject
        private EnvironmentEndpoint environmentEndpoint;

        @Inject
        private WebApplicationExceptionMessageExtractor webApplicationExceptionMessageExtractor;

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating environment stack config");
            try {
                if (!isRepair(variables) || !isChainedAction(variables) || isFinalChain(variables)) {
                    ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> environmentEndpoint.updateConfigsInEnvironmentByCrn(stack.getEnvironmentCrn()));
                }
                sendEvent(context, DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
            } catch (ClientErrorException e) {
                String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
                LOGGER.error("Failed to update the stack config due to {}", errorMessage, e);
                sendEvent(context, DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT.selector(), new DownscaleFailureEvent(stack.getId(), "Updating environment stack config", Set.of(), Map.of(), e));
            } catch (Exception e) {
                LOGGER.error("Failed to update the stack config", e);
                sendEvent(context, DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT.selector(), new DownscaleFailureEvent(stack.getId(), "Updating environment stack config", Set.of(), Map.of(), e));
            }
        }
    };
}
Also used : EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) WebApplicationExceptionMessageExtractor(com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) ClientErrorException(javax.ws.rs.ClientErrorException) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) Map(java.util.Map) ClientErrorException(javax.ws.rs.ClientErrorException) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 8 with DownscaleFailureEvent

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method updateKerberosNameserversConfigAction.

@Bean(name = "DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_STATE")
public Action<?, ?> updateKerberosNameserversConfigAction() {
    return new AbstractDownscaleAction<>(StackEvent.class) {

        @Inject
        private KerberosConfigUpdateService kerberosConfigUpdateService;

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating kerberos nameserver config");
            try {
                kerberosConfigUpdateService.updateNameservers(stack.getId());
                sendEvent(context, DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
            } catch (Exception e) {
                LOGGER.error("Failed to update the kerberos nameserver config", e);
                sendEvent(context, DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FAILED_EVENT.selector(), new DownscaleFailureEvent(stack.getId(), "Updating kerberos nameserver config", Set.of(), Map.of(), e));
            }
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) KerberosConfigUpdateService(com.sequenceiq.freeipa.service.config.KerberosConfigUpdateService) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) Map(java.util.Map) ClientErrorException(javax.ws.rs.ClientErrorException) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 9 with DownscaleFailureEvent

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.

the class DownscaleStackResultToDownscaleFailureEventConverter method convert.

@Override
public DownscaleFailureEvent convert(Object payload) {
    DownscaleStackResult downscaleStackResult = (DownscaleStackResult) payload;
    DownscaleFailureEvent event = new DownscaleFailureEvent(downscaleStackResult.getResourceId(), "Downscale Stack", Set.of(), Map.of(), new Exception("Payload failed: " + payload));
    return event;
}
Also used : DownscaleStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackResult) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)

Example 10 with DownscaleFailureEvent

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.

the class RemoveDnsResponseToDownscaleFailureEventConverter method convert.

@Override
public DownscaleFailureEvent convert(Object payload) {
    RemoveDnsResponse removeDnsResponse = (RemoveDnsResponse) payload;
    DownscaleFailureEvent event = new DownscaleFailureEvent(removeDnsResponse.getResourceId(), "DNS record removal", removeDnsResponse.getDnsCleanupSuccess(), removeDnsResponse.getDnsCleanupFailed(), new Exception("Payload failed: " + payload));
    return event;
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)

Aggregations

DownscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)14 Stack (com.sequenceiq.freeipa.entity.Stack)5 Map (java.util.Map)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)3 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)3 Bean (org.springframework.context.annotation.Bean)3 EventSelectorUtil (com.sequenceiq.flow.event.EventSelectorUtil)2 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)2 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 ClientErrorException (javax.ws.rs.ClientErrorException)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Component (org.springframework.stereotype.Component)2 Event (reactor.bus.Event)2 DownscaleStackCollectResourcesResult (com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult)1 DownscaleStackResult (com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackResult)1