use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeFreeIpaStatusValidation.
@Bean(name = "CLUSTER_UPGRADE_FREEIPA_STATUS_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeFreeIpaStatusValidation() {
return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent.class) {
@Override
protected void doExecute(StackContext context, ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent payload, Map<Object, Object> variables) {
LOGGER.info("Starting the validation if FreeIPA is reachable...");
ClusterUpgradeFreeIpaStatusValidationEvent event = new ClusterUpgradeFreeIpaStatusValidationEvent(payload.getResourceId());
sendEvent(context, event.selector(), event);
}
@Override
protected Object getFailurePayload(ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent 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.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> event) {
LOGGER.debug("Accepting Cluster upgrade existing upgradeCDH command validation event.");
ClusterUpgradeExistingUpgradeCommandValidationEvent request = event.getData();
Image targetImage = request.getImage();
Long stackId = request.getResourceId();
Stack stack = getStack(stackId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
Optional<ClusterManagerCommand> optionalUpgradeCommand = connector.clusterStatusService().findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER);
if (optionalUpgradeCommand.isEmpty()) {
LOGGER.debug("There is no existing upgradeCDH command, validation passed successfully");
return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
} else {
ClusterManagerCommand upgradeCommand = optionalUpgradeCommand.get();
if (upgradeCommand.getActive() || (!upgradeCommand.getSuccess() && upgradeCommand.getRetryable())) {
return validateIfExistingRuntimeMatchesTargetRuntime(stack, connector, targetImage);
} else {
LOGGER.debug("There is no retryable upgradeCDH command, validation passed successfully");
return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
}
}
}
Aggregations