Search in sources :

Example 6 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException in project cloudbreak by hortonworks.

the class ActiveCommandsValidator method validate.

@Override
public void validate(ServiceUpgradeValidationRequest validationRequest) {
    ClusterApi connector = clusterApiConnectors.getConnector(validationRequest.getStack());
    List<String> activeCommands = connector.clusterStatusService().getActiveCommandsList();
    if (CollectionUtils.isNotEmpty(activeCommands)) {
        throw new UpgradeValidationFailedException("There are active commands running on CM, upgrade is not possible. Active commands: " + String.join(",", activeCommands));
    }
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 7 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException in project cloudbreak by hortonworks.

the class ClusterUpgradeDiskSpaceValidationHandlerTest method testHandlerShouldReturnValidationFailedEventWhenTheDiskValidationFailed.

@Test
public void testHandlerShouldReturnValidationFailedEventWhenTheDiskValidationFailed() {
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    doThrow(new UpgradeValidationFailedException("Validation failed")).when(diskSpaceValidationService).validateFreeSpaceForUpgrade(stack, REQUIRED_FREE_SPACE);
    Selectable nextFlowStepSelector = underTest.doAccept(createEvent());
    assertEquals(FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.name(), nextFlowStepSelector.selector());
    verify(stackService).getByIdWithListsInTransaction(STACK_ID);
    verify(diskSpaceValidationService).validateFreeSpaceForUpgrade(stack, REQUIRED_FREE_SPACE);
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) Test(org.junit.Test)

Example 8 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException in project cloudbreak by hortonworks.

the class ClusterUpgradeImageValidationHandlerTest method testDoAcceptShouldReturnWithFailureEventWhenTheTheParcelsAreNotAvailable.

@Test
void testDoAcceptShouldReturnWithFailureEventWhenTheTheParcelsAreNotAvailable() {
    HandlerEvent<ClusterUpgradeImageValidationEvent> event = getHandlerEvent();
    ClusterUpgradeImageValidationEvent request = event.getData();
    when(parcelAvailabilityService.validateAvailability(request.getTargetImage(), request.getResourceId())).thenThrow(new UpgradeValidationFailedException("Failed to get parcels."));
    Selectable nextFlowStepSelector = underTest.doAccept(event);
    assertEquals(FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
    verify(parcelAvailabilityService).validateAvailability(request.getTargetImage(), request.getResourceId());
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterUpgradeImageValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) Test(org.junit.jupiter.api.Test)

Example 9 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException in project cloudbreak by hortonworks.

the class DatalakeUpgradeWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeUpgradeWaitRequest> event) {
    DatalakeUpgradeWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling cluster upgrade process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Stack Upgrade");
        response = new DatalakeImageChangeEvent(sdxId, userId, request.getImageId());
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Upgrade polling exited before timeout. Cause: ", userBreakException);
        if (userBreakException.getCause() instanceof UpgradeValidationFailedException) {
            response = new DatalakeUpgradeValidationFailedEvent(sdxId, userId);
        } else {
            response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
        }
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Upgrade poller stopped for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Datalake upgrade timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Upgrade polling failed for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeUpgradeWaitRequest(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeImageChangeEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeImageChangeEvent) DatalakeUpgradeValidationFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeValidationFailedEvent) DatalakeUpgradeFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 10 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException in project cloudbreak by hortonworks.

the class SdxUpgradeService method waitCloudbreakFlow.

public void waitCloudbreakFlow(Long id, PollingConfig pollingConfig, String pollingMessage) {
    SdxCluster sdxCluster = sdxService.getById(id);
    cloudbreakPoller.pollUpdateUntilAvailable(pollingMessage, sdxCluster, pollingConfig);
    if (cloudbreakFlowResultProvider.isValidationFailed(sdxCluster)) {
        throw new UserBreakException(new UpgradeValidationFailedException("Upgrade validation failed."));
    }
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Aggregations

UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)11 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)3 UserBreakException (com.dyngr.exception.UserBreakException)2 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)2 ClusterUpgradeDiskSpaceValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent)2 PollerException (com.dyngr.exception.PollerException)1 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 ClusterUpgradeImageValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent)1 ClusterUpgradeDiskSpaceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent)1 ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent)1 ClusterUpgradeFreeIpaStatusValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent)1 ClusterUpgradeFreeIpaStatusValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent)1 ClusterUpgradeServiceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent)1 ClusterUpgradeValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent)1 ClusterUpgradeValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)1 ServiceUpgradeValidationRequest (com.sequenceiq.cloudbreak.service.upgrade.validation.service.ServiceUpgradeValidationRequest)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1