Search in sources :

Example 6 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmOnDatahubHandler method accept.

@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
    LOGGER.debug("In UpgradeCcmOnDatahubHandler.accept");
    EnvironmentDto environmentDto = environmentDtoEvent.getData();
    try {
        // TODO action here
        UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.FINISH_UPGRADE_CCM_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
        eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
        LOGGER.debug("FINISH_UPGRADE_CCM_EVENT event sent");
    } catch (Exception e) {
        UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_DATAHUB_FAILED);
        eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
        LOGGER.debug("UPGRADE_CCM_ON_DATAHUB_FAILED event sent");
    }
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) UpgradeCcmFailedEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto)

Example 7 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmOnDatalakeHandler method accept.

@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
    LOGGER.debug("In UpgradeCcmOnDatalakeHandler.accept");
    EnvironmentDto environmentDto = environmentDtoEvent.getData();
    try {
        LOGGER.debug("Calling Upgrade CCM endpoint on data lake service");
        SdxCcmUpgradeResponse ccmUpgradeResponse = sdxService.upgradeCcm(environmentDto.getResourceCrn());
        switch(ccmUpgradeResponse.getResponseType()) {
            case ERROR:
                String message = String.format("Upgrade CCM returned with reason: %s", ccmUpgradeResponse.getReason());
                LOGGER.warn(message);
                sendFailedEvent(environmentDtoEvent, environmentDto, new OperationException(message));
                return;
            case TRIGGERED:
                LOGGER.debug("Waiting for data lake Upgrade CCM flow to finish.");
                pollerService.waitForUpgradeCcm(environmentDto.getId(), ccmUpgradeResponse.getResourceCrn());
                break;
            case SKIP:
                LOGGER.debug("Upgrade CCM is skipped due to {}", ccmUpgradeResponse.getReason());
                break;
            default:
                message = String.format("Unknown response type: %s", ccmUpgradeResponse.getResponseType());
                LOGGER.warn(message);
                sendFailedEvent(environmentDtoEvent, environmentDto, new OperationException(message));
                return;
        }
        UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_DATAHUB_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
        eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
        LOGGER.debug("UPGRADE_CCM_DATAHUB_EVENT event sent");
    } catch (Exception e) {
        sendFailedEvent(environmentDtoEvent, environmentDto, e);
    }
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) OperationException(com.sequenceiq.cloudbreak.service.OperationException) OperationException(com.sequenceiq.cloudbreak.service.OperationException)

Example 8 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmOnFreeIpaHandler method accept.

@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
    LOGGER.debug("In UpgradeCcmOnFreeIpaHandler.accept");
    EnvironmentDto environmentDto = environmentDtoEvent.getData();
    try {
        freeIpaService.describe(environmentDto.getResourceCrn()).ifPresentOrElse(freeIpa -> {
            if (freeIpa.getStatus() == null || freeIpa.getAvailabilityStatus() == null) {
                throw new FreeIpaOperationFailedException("FreeIPA status is unpredictable, upgrading of Cluster Connectivity Manager will be interrupted.");
            } else if (!freeIpa.getStatus().isCcmUpgradeablePhase()) {
                throw new FreeIpaOperationFailedException("FreeIPA is not in a valid state to upgrade Cluster Connectivity Manager. Current state is: " + freeIpa.getStatus().name());
            } else {
                LOGGER.info("CCM on FreeIPA will be upgraded.");
                freeIpaPollerService.waitForCcmUpgrade(environmentDto.getId(), environmentDto.getResourceCrn());
            }
            UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_TUNNEL_UPDATE_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
            eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
            LOGGER.debug("UPGRADE_CCM_TUNNEL_UPDATE_EVENT event sent");
        }, () -> {
            throw new FreeIpaOperationFailedException(String.format("FreeIPA cannot be found for environment %s", environmentDto.getName()));
        });
    } catch (Exception e) {
        UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_FAILED);
        eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
        LOGGER.debug("UPGRADE_CCM_ON_FREEIPA_FAILED event sent");
    }
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) UpgradeCcmFailedEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException)

Example 9 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class ValidateUpgradeCcmHandler method accept.

@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
    LOGGER.debug("In ValidateUpgradeCcmHandler.accept");
    EnvironmentDto environmentDto = environmentDtoEvent.getData();
    try {
        UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_FREEIPA_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
        eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
        LOGGER.debug("UPGRADE_CCM_FREEIPA_EVENT event sent");
    } catch (Exception e) {
        UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_VALIDATION_FAILED);
        eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
        LOGGER.debug("UPGRADE_CCM_VALIDATION_FAILED event sent");
    }
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) UpgradeCcmFailedEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto)

Example 10 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmActions method upgradeCcmInFreeIpaAction.

@Bean(name = "UPGRADE_CCM_FREEIPA_STATE")
public Action<?, ?> upgradeCcmInFreeIpaAction() {
    return new AbstractUpgradeCcmAction<>(UpgradeCcmEvent.class) {

        @Override
        protected void doExecute(CommonContext context, UpgradeCcmEvent payload, Map<Object, Object> variables) {
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_IN_PROGRESS, ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_FREEIPA_STARTED, UpgradeCcmState.UPGRADE_CCM_FREEIPA_STATE);
            sendEvent(context, UPGRADE_CCM_FREEIPA_HANDLER.selector(), envDto);
        }
    };
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

UpgradeCcmEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent)17 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)11 CommonContext (com.sequenceiq.flow.core.CommonContext)6 Map (java.util.Map)6 Bean (org.springframework.context.annotation.Bean)6 UpgradeCcmFailedEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)4 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 SdxCcmUpgradeResponse (com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse)3 Test (org.junit.jupiter.api.Test)3 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 EnvStackConfigUpdatesEvent (com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesEvent)1 EnvCreationEvent (com.sequenceiq.environment.environment.flow.creation.event.EnvCreationEvent)1 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)1 LoadBalancerUpdateEvent (com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateEvent)1 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)1 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)1 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1