Search in sources :

Example 1 with ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeValidationActions method clusterUpgradeFreeIpaStatusValidation.

@Bean(name = "CLUSTER_UPGRADE_FREEIPA_STATUS_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeFreeIpaStatusValidation() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Starting the validation if FreeIPA is reachable...");
            ClusterUpgradeFreeIpaStatusValidationEvent event = new ClusterUpgradeFreeIpaStatusValidationEvent(payload.getResourceId());
            sendEvent(context, event.selector(), event);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : ClusterUpgradeFreeIpaStatusValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent) Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent) Map(java.util.Map) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent) Bean(org.springframework.context.annotation.Bean)

Example 2 with ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeExistingUpgradeCommandValidationHandler method validateIfExistingRuntimeMatchesTargetRuntime.

private StackEvent validateIfExistingRuntimeMatchesTargetRuntime(Stack stack, ClusterApi connector, Image targetImage) {
    String activeRuntimeParcelVersion = getActiveRuntimeParcelVersion(stack, connector);
    String targetRuntimeBuildNumber = getTargetRuntimeBuildNumber(targetImage);
    Long stackId = stack.getId();
    if (StringUtils.isEmpty(activeRuntimeParcelVersion)) {
        String message = "There is an existing upgradeCDH command but active parcel version could not be queried from CM, validation passed successfully";
        LOGGER.debug(message);
        return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
    } else if (activeRuntimeParcelVersion.endsWith(targetRuntimeBuildNumber)) {
        String message = String.format("There is an existing upgradeCDH command with the same build number %s, validation passed successfully", targetRuntimeBuildNumber);
        LOGGER.debug(message);
        return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
    } else {
        String msg = String.format("Existing upgrade command found for active runtime %s, " + "upgrading to a different runtime version (%s-%s) is not allowed! " + "Possible solutions: " + "#1, retry the upgrade with the same target runtime. " + "#2, complete the upgrade manually in Cloudera Manager. " + "#3, recover the cluster", activeRuntimeParcelVersion, getTargetRuntimeVersion(targetImage), targetRuntimeBuildNumber);
        LOGGER.debug(msg);
        return new ClusterUpgradeValidationFailureEvent(stackId, new UpgradeValidationFailedException(msg));
    }
}
Also used : ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 3 with ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeExistingUpgradeCommandValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade existing upgradeCDH command validation event.");
    ClusterUpgradeExistingUpgradeCommandValidationEvent request = event.getData();
    Image targetImage = request.getImage();
    Long stackId = request.getResourceId();
    Stack stack = getStack(stackId);
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    Optional<ClusterManagerCommand> optionalUpgradeCommand = connector.clusterStatusService().findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER);
    if (optionalUpgradeCommand.isEmpty()) {
        LOGGER.debug("There is no existing upgradeCDH command, validation passed successfully");
        return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
    } else {
        ClusterManagerCommand upgradeCommand = optionalUpgradeCommand.get();
        if (upgradeCommand.getActive() || (!upgradeCommand.getSuccess() && upgradeCommand.getRetryable())) {
            return validateIfExistingRuntimeMatchesTargetRuntime(stack, connector, targetImage);
        } else {
            LOGGER.debug("There is no retryable upgradeCDH command, validation passed successfully");
            return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
        }
    }
}
Also used : ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent)3 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)1 ClusterManagerCommand (com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand)1 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent)1 ClusterUpgradeExistingUpgradeCommandValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent)1 ClusterUpgradeFreeIpaStatusValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent)1 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1