use of com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand 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);
}
}
}
use of com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusService method convertApiCommand.
private ClusterManagerCommand convertApiCommand(ApiCommand apiCommand) {
if (Objects.isNull(apiCommand)) {
return null;
}
ClusterManagerCommand command = new ClusterManagerCommand();
command.setId(apiCommand.getId());
command.setName(apiCommand.getName());
command.setSuccess(apiCommand.getSuccess());
command.setActive(apiCommand.getActive());
command.setRetryable(apiCommand.getCanRetry());
command.setEndTime(apiCommand.getEndTime());
command.setResultMessage(apiCommand.getResultMessage());
command.setStartTime(apiCommand.getStartTime());
return command;
}
use of com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveNotSuccessfulRetryableAndEmptyactiveRuntimeParcelVersionThenValidationShouldPass.
@Test
public void testUpgradeCommandNotActiveNotSuccessfulRetryableAndEmptyactiveRuntimeParcelVersionThenValidationShouldPass() {
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();
when(connector.gatherInstalledParcels(STACK_NAME)).thenReturn(parcelNameToVersionMap);
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent());
assertEquals(FINISH_CLUSTER_UPGRADE_EXISTING_UPGRADE_COMMAND_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
}
use of com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveSuccessfulNotRetryableThenValidationShouldPass.
@Test
public void testUpgradeCommandNotActiveSuccessfulNotRetryableThenValidationShouldPass() {
ClusterManagerCommand command = new ClusterManagerCommand();
command.setActive(false);
command.setSuccess(true);
command.setRetryable(false);
when(clusterStatusService.findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER)).thenReturn(Optional.of(command));
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent());
assertEquals(FINISH_CLUSTER_UPGRADE_EXISTING_UPGRADE_COMMAND_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
}
use of com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand 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