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));
}
}
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);
}
}
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()));
}
}
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());
}
}
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);
}
}
Aggregations