Search in sources :

Example 1 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException 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 2 with UpgradeValidationFailedException

use of com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException 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 3 with UpgradeValidationFailedException

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

the class NifiUpgradeValidator method validateNifiWorkingDirectory.

private void validateNifiWorkingDirectory(Stack stack) {
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    Optional<String> nifiWorkingDirectory = connector.getRoleConfigValueByServiceType(stack.getCluster().getName(), ROLE_TYPE, NIFI_SERVICE_TYPE, NIFI_WORKING_DIRECTORY);
    LOGGER.debug("Validating Nifi working directory: {}", nifiWorkingDirectory);
    if (nifiWorkingDirectory.isPresent() && nifiWorkingDirectory.get().startsWith(VolumeUtils.VOLUME_PREFIX)) {
        LOGGER.debug("Nifi working directory validation was successful");
    } else {
        throw new UpgradeValidationFailedException(String.format("Nifi working directory validation failed. The current directory %s is not eligible for upgrade.", nifiWorkingDirectory.get()));
    }
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 4 with UpgradeValidationFailedException

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

the class ClusterUpgradeDiskSpaceValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeDiskSpaceValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade validation event.");
    ClusterUpgradeDiskSpaceValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    try {
        diskSpaceValidationService.validateFreeSpaceForUpgrade(getStack(stackId), request.getRequiredFreeSpace());
        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 : ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) 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)

Example 5 with UpgradeValidationFailedException

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

the class ClusterUpgradeServiceValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeServiceValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade service validation event.");
    ClusterUpgradeServiceValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    try {
        Stack stack = getStack(stackId);
        serviceUpgradeValidators.forEach(validator -> validator.validate(new ServiceUpgradeValidationRequest(stack, request.isLockComponents())));
        return new ClusterUpgradeValidationFinishedEvent(stackId);
    } catch (UpgradeValidationFailedException e) {
        LOGGER.warn("Cluster upgrade service validation failed", e);
        return new ClusterUpgradeValidationFailureEvent(stackId, e);
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade service validation was unsuccessful due to an internal error", e);
        return new ClusterUpgradeValidationFinishedEvent(stackId, e);
    }
}
Also used : ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) ClusterUpgradeServiceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent) ServiceUpgradeValidationRequest(com.sequenceiq.cloudbreak.service.upgrade.validation.service.ServiceUpgradeValidationRequest) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)

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