use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeCheckCloudProviderUpdate.
@Bean(name = "CLUSTER_UPGRADE_CLOUDPROVIDER_CHECK_UPDATE_STATE")
public Action<?, ?> clusterUpgradeCheckCloudProviderUpdate() {
return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeDiskSpaceValidationFinishedEvent.class) {
@Override
protected void doExecute(StackContext context, ClusterUpgradeDiskSpaceValidationFinishedEvent payload, Map<Object, Object> variables) {
Collection<Resource> resources = resourceService.getAllByStackId(context.getStack().getId());
List<CloudResource> cloudResources = resources.stream().map(resource -> resourceToCloudResourceConverter.convert(resource)).collect(Collectors.toList());
ClusterUpgradeUpdateCheckRequest clusterUpgradeUpdateCheckRequest = new ClusterUpgradeUpdateCheckRequest(payload.getResourceId(), context.getCloudStack(), context.getCloudCredential(), context.getCloudContext(), cloudResources);
sendEvent(context, VALIDATE_CLOUDPROVIDER_UPDATE.selector(), clusterUpgradeUpdateCheckRequest);
}
@Override
protected Object getFailurePayload(ClusterUpgradeDiskSpaceValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent 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.ClusterUpgradeValidationFailureEvent 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.ClusterUpgradeValidationFailureEvent 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.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildNotMatchThenValidationShouldFail.
@Test
public void testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildNotMatchThenValidationShouldFail() {
ClusterManagerCommand command = new ClusterManagerCommand();
command.setActive(false);
command.setSuccess(false);
command.setRetryable(true);
when(clusterStatusService.findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER)).thenReturn(Optional.of(command));
Map<String, String> parcelNameToVersionMap = Map.of(CDH, "7.2.7-1.cdh7.2.7.p7.12569826");
when(connector.gatherInstalledParcels(STACK_NAME)).thenReturn(parcelNameToVersionMap);
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent("23569826"));
assertEquals(FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
String expectedMessage = "Existing upgrade command found for active runtime 7.2.7-1.cdh7.2.7.p7.12569826, upgrading to a different runtime version " + "(7.2.7-23569826) 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";
assertEquals(expectedMessage, ((ClusterUpgradeValidationFailureEvent) nextFlowStepSelector).getException().getMessage());
}
Aggregations