Search in sources :

Example 1 with ClusterUpgradeValidationEvent

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

the class ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverterTest method testConvertShouldCreateAClusterUpgradeDiskSpaceValidationEvent.

@Test
public void testConvertShouldCreateAClusterUpgradeDiskSpaceValidationEvent() {
    ClusterUpgradeValidationEvent sourceEvent = new ClusterUpgradeValidationEvent(VALIDATE_DISK_SPACE_EVENT.event(), RESOURCE_ID, "image-id");
    ClusterUpgradeDiskSpaceValidationEvent actual = underTest.convert(sourceEvent);
    assertEquals(RESOURCE_ID, actual.getResourceId());
    assertEquals(1L, actual.getRequiredFreeSpace());
}
Also used : ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) Test(org.junit.jupiter.api.Test)

Example 2 with ClusterUpgradeValidationEvent

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

the class ClusterUpgradeValidationActions method clusterUpgradeImageValidation.

@Bean(name = "CLUSTER_UPGRADE_IMAGE_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeImageValidation() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeValidationEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeValidationEvent payload, Map<Object, Object> variables) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
            LOGGER.info("Starting cluster upgrade image validation.");
            UpgradeImageInfo upgradeImageInfo = upgradeImageInfoFactory.create(payload.getImageId(), payload.getResourceId());
            Image targetImage = stackImageService.getImageModelFromStatedImage(context.getStack(), upgradeImageInfo.getCurrentImage(), upgradeImageInfo.getTargetStatedImage());
            variables.put(TARGET_IMAGE, targetImage);
            CloudStack cloudStack = context.getCloudStack().replaceImage(targetImage);
            ClusterUpgradeImageValidationEvent event = new ClusterUpgradeImageValidationEvent(payload.getResourceId(), payload.getImageId(), cloudStack, context.getCloudCredential(), context.getCloudContext(), upgradeImageInfo.getTargetStatedImage().getImage());
            sendEvent(context, event.selector(), event);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeValidationEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) UpgradeImageInfo(com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) 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 ClusterUpgradeValidationEvent

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

the class ClusterUpgradeValidationActions method initClusterUpgradeValidation.

@Bean(name = "CLUSTER_UPGRADE_VALIDATION_INIT_STATE")
public Action<?, ?> initClusterUpgradeValidation() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeValidationTriggerEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeValidationTriggerEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Starting cluster upgrade validation flow. Target image: {}", payload.getImageId());
            cloudbreakEventService.fireCloudbreakEvent(payload.getResourceId(), UPDATE_IN_PROGRESS.name(), ResourceEvent.CLUSTER_UPGRADE_VALIDATION_STARTED);
            variables.put(LOCK_COMPONENTS, payload.isLockComponents());
            ClusterUpgradeValidationEvent event = new ClusterUpgradeValidationEvent(START_CLUSTER_UPGRADE_IMAGE_VALIDATION_EVENT.name(), payload.getResourceId(), payload.getImageId());
            sendEvent(context, event.selector(), event);
        }

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

Example 4 with ClusterUpgradeValidationEvent

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

the class ClusterUpgradeDiskSpaceValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade validation event.");
    ClusterUpgradeValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    try {
        StatedImage targetImage = imageService.getCurrentImage(stackId);
        diskSpaceValidationService.validateFreeSpaceForUpgrade(getStack(stackId), targetImage);
        return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
    } catch (UpgradeValidationFailedException e) {
        LOGGER.warn("Cluster upgrade validation failed", e);
        return new ClusterUpgradeValidationFailureEvent(stackId, e);
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade validation was unsuccessful due to an internal error", e);
        return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
    }
}
Also used : ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)

Aggregations

ClusterUpgradeValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent)4 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)2 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Bean (org.springframework.context.annotation.Bean)2 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)1 ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent)1 ClusterUpgradeDiskSpaceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent)1 ClusterUpgradeDiskSpaceValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent)1 ClusterUpgradeValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent)1 ClusterUpgradeValidationTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent)1 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)1 UpgradeImageInfo (com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo)1 Test (org.junit.jupiter.api.Test)1