Search in sources :

Example 1 with ClusterUpgradeValidationFailureEvent

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

the class ClusterUpgradeValidationActions method clusterUpgradeCheckCloudProviderUpdate.

@Bean(name = "CLUSTER_UPGRADE_CLOUDPROVIDER_CHECK_UPDATE_STATE")
public Action<?, ?> clusterUpgradeCheckCloudProviderUpdate() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeDiskSpaceValidationFinishedEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeDiskSpaceValidationFinishedEvent payload, Map<Object, Object> variables) {
            Collection<Resource> resources = resourceService.getAllByStackId(context.getStack().getId());
            List<CloudResource> cloudResources = resources.stream().map(resource -> resourceToCloudResourceConverter.convert(resource)).collect(Collectors.toList());
            ClusterUpgradeUpdateCheckRequest clusterUpgradeUpdateCheckRequest = new ClusterUpgradeUpdateCheckRequest(payload.getResourceId(), context.getCloudStack(), context.getCloudCredential(), context.getCloudContext(), cloudResources);
            sendEvent(context, VALIDATE_CLOUDPROVIDER_UPDATE.selector(), clusterUpgradeUpdateCheckRequest);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeDiskSpaceValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Action(org.springframework.statemachine.action.Action) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Resource(com.sequenceiq.cloudbreak.domain.Resource) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) ClusterUpgradeFreeIpaStatusValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent) UpgradeImageInfoFactory(com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfoFactory) ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) CloudbreakMessagesService(com.sequenceiq.cloudbreak.message.CloudbreakMessagesService) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) START_CLUSTER_UPGRADE_IMAGE_VALIDATION_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationStateSelectors.START_CLUSTER_UPGRADE_IMAGE_VALIDATION_EVENT) Map(java.util.Map) ClusterUpgradeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) VALIDATE_DISK_SPACE_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationHandlerSelectors.VALIDATE_DISK_SPACE_EVENT) ClusterUpgradeContext(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.ClusterUpgradeContext) UPDATE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED) PayloadConverter(com.sequenceiq.flow.core.PayloadConverter) VALIDATE_CLOUDPROVIDER_UPDATE(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationHandlerSelectors.VALIDATE_CLOUDPROVIDER_UPDATE) Collection(java.util.Collection) ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) FlowParameters(com.sequenceiq.flow.core.FlowParameters) ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent) Collectors(java.util.stream.Collectors) UpgradeImageInfo(com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo) Configuration(org.springframework.context.annotation.Configuration) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) List(java.util.List) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) ClusterUpgradeUpdateCheckFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckFinishedEvent) Optional(java.util.Optional) Flow(com.sequenceiq.flow.core.Flow) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter) AbstractAction(com.sequenceiq.flow.core.AbstractAction) Inject(javax.inject.Inject) ResourceToCloudResourceConverter(com.sequenceiq.cloudbreak.converter.spi.ResourceToCloudResourceConverter) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) ClusterUpgradeUpdateCheckRequest(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckRequest) ClusterUpgradeValidationStateSelectors(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationStateSelectors) UPDATE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS) StateContext(org.springframework.statemachine.StateContext) Logger(org.slf4j.Logger) StackImageService(com.sequenceiq.cloudbreak.service.stack.StackImageService) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) ClusterUpgradeServiceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent) ClusterUpgradeValidationFinalizeEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinalizeEvent) ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) HANDLED_FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationStateSelectors.HANDLED_FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT) Bean(org.springframework.context.annotation.Bean) Collections(java.util.Collections) ClusterUpgradeFreeIpaStatusValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent) Optional(java.util.Optional) Resource(com.sequenceiq.cloudbreak.domain.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ClusterUpgradeUpdateCheckRequest(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckRequest) Map(java.util.Map) 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 ClusterUpgradeValidationFailureEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent 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 3 with ClusterUpgradeValidationFailureEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent 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 4 with ClusterUpgradeValidationFailureEvent

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

the class ClusterUpgradeFreeIpaStatusValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeFreeIpaStatusValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade FreeIPA status validation event.");
    ClusterUpgradeFreeIpaStatusValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    String environmentCrn = getStack(stackId).getEnvironmentCrn();
    if (!freeipaService.checkFreeipaRunning(environmentCrn)) {
        String message = "Upgrade cannot be performed because the FreeIPA isn't available. Please check the FreeIPA state and try again.";
        LOGGER.info("FreeIPA status validation failed with: {}", message);
        return new ClusterUpgradeValidationFailureEvent(stackId, new UpgradeValidationFailedException(message));
    } else {
        LOGGER.debug("FreeIPA status validation passed successfully");
        return new ClusterUpgradeFreeIpaStatusValidationFinishedEvent(stackId);
    }
}
Also used : ClusterUpgradeFreeIpaStatusValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent) ClusterUpgradeFreeIpaStatusValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 5 with ClusterUpgradeValidationFailureEvent

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

the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildNotMatchThenValidationShouldFail.

@Test
public void testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildNotMatchThenValidationShouldFail() {
    ClusterManagerCommand command = new ClusterManagerCommand();
    command.setActive(false);
    command.setSuccess(false);
    command.setRetryable(true);
    when(clusterStatusService.findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER)).thenReturn(Optional.of(command));
    Map<String, String> parcelNameToVersionMap = Map.of(CDH, "7.2.7-1.cdh7.2.7.p7.12569826");
    when(connector.gatherInstalledParcels(STACK_NAME)).thenReturn(parcelNameToVersionMap);
    Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent("23569826"));
    assertEquals(FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
    String expectedMessage = "Existing upgrade command found for active runtime 7.2.7-1.cdh7.2.7.p7.12569826, upgrading to a different runtime version " + "(7.2.7-23569826) 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";
    assertEquals(expectedMessage, ((ClusterUpgradeValidationFailureEvent) nextFlowStepSelector).getException().getMessage());
}
Also used : ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) Test(org.junit.Test)

Aggregations

ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)13 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)5 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)5 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)5 ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent)5 Map (java.util.Map)5 Optional (java.util.Optional)5 Bean (org.springframework.context.annotation.Bean)5 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)4 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 ClusterUpgradeDiskSpaceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent)3 ClusterUpgradeDiskSpaceValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent)3 ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent)3 ClusterUpgradeFreeIpaStatusValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent)3 ClusterUpgradeValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent)3 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)2 ClusterUpgradeContext (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.ClusterUpgradeContext)2 ClusterUpgradeExistingUpgradeCommandValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent)2 ClusterUpgradeFreeIpaStatusValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent)2