Search in sources :

Example 1 with ClusterUpgradeImageValidationEvent

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

the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method getHandlerEvent.

private HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> getHandlerEvent(String buildNumber) {
    Image targetImage = mock(Image.class);
    Map<String, String> packageVersions = new java.util.HashMap<>();
    packageVersions.put(ImagePackageVersion.CDH_BUILD_NUMBER.getKey(), buildNumber);
    packageVersions.put(ImagePackageVersion.STACK.getKey(), STACK_VERSION);
    when(targetImage.getPackageVersions()).thenReturn(packageVersions);
    ClusterUpgradeExistingUpgradeCommandValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeExistingUpgradeCommandValidationEvent(1L, targetImage);
    HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> handlerEvent = mock(HandlerEvent.class);
    when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
    return handlerEvent;
}
Also used : ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 2 with ClusterUpgradeImageValidationEvent

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

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

the class ClusterUpgradeImageValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeImageValidationEvent> event) {
    LOGGER.debug("Accepting cluster upgrade image validation event.");
    ClusterUpgradeImageValidationEvent request = event.getData();
    CloudContext cloudContext = request.getCloudContext();
    try {
        Set<Response> parcelsResponses = parcelAvailabilityService.validateAvailability(request.getTargetImage(), request.getResourceId());
        long requiredDiskSpaceForUpgrade = parcelSizeService.getRequiredFreeSpace(parcelsResponses);
        executePlatformSpecificValidations(request, cloudContext);
        LOGGER.debug("Cluster upgrade image validation succeeded.");
        return new ClusterUpgradeDiskSpaceValidationEvent(START_CLUSTER_UPGRADE_DISK_SPACE_VALIDATION_EVENT.selector(), request.getResourceId(), requiredDiskSpaceForUpgrade);
    } catch (RuntimeException e) {
        LOGGER.warn("Cluster upgrade image validation failed: ", e);
        return new ClusterUpgradeValidationFailureEvent(request.getResourceId(), e);
    }
}
Also used : Response(javax.ws.rs.core.Response) ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) ClusterUpgradeImageValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)

Example 4 with ClusterUpgradeImageValidationEvent

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

the class ClusterUpgradeFreeIpaStatusValidationHandlerTest method getHandlerEvent.

private HandlerEvent<ClusterUpgradeFreeIpaStatusValidationEvent> getHandlerEvent() {
    ClusterUpgradeFreeIpaStatusValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeFreeIpaStatusValidationEvent(1L);
    HandlerEvent<ClusterUpgradeFreeIpaStatusValidationEvent> handlerEvent = mock(HandlerEvent.class);
    when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
    return handlerEvent;
}
Also used : ClusterUpgradeFreeIpaStatusValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent)

Example 5 with ClusterUpgradeImageValidationEvent

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

the class ClusterUpgradeImageValidationHandlerTest method getHandlerEvent.

private HandlerEvent<ClusterUpgradeImageValidationEvent> getHandlerEvent() {
    ClusterUpgradeImageValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeImageValidationEvent(1L, "imageId", cloudStack, cloudCredential, cloudContext, mock(Image.class));
    HandlerEvent<ClusterUpgradeImageValidationEvent> handlerEvent = mock(HandlerEvent.class);
    when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
    return handlerEvent;
}
Also used : ClusterUpgradeImageValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image)

Aggregations

ClusterUpgradeImageValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent)4 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)2 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.jupiter.api.Test)2 Validator (com.sequenceiq.cloudbreak.cloud.Validator)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)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 ClusterUpgradeDiskSpaceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent)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 ClusterUpgradeValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent)1 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 UpgradeImageInfo (com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo)1