Search in sources :

Example 6 with ClouderaManagerOperationFailedException

use of com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerTemplateInstallationCheckerTest method checkStatusWithMultiLevelMessage.

@Test
void checkStatusWithMultiLevelMessage() throws ApiException {
    ApiCommand addRepositoriesCmd = addReposCmd();
    ApiCommand deployParcelsCmd = deployParcelsCmd();
    ApiCommand firstRunCmd = firstRunCmd().success(Boolean.FALSE).resultMessage("Failed to perform First Run of services.");
    ApiCommand templateInstallCmd = templateInstallCmd(addRepositoriesCmd, deployParcelsCmd, firstRunCmd).resultMessage("Failed to import cluster template");
    expectReadCommandForFailedCommands(templateInstallCmd);
    ClouderaManagerOperationFailedException ex = assertThrowsExact(ClouderaManagerOperationFailedException.class, () -> underTest.checkStatus(pollerObject));
    String expected = expectMessageForCommands(firstRunCmd);
    assertEquals(expected, ex.getMessage());
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 7 with ClouderaManagerOperationFailedException

use of com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerTemplateInstallationCheckerTest method checkStatusWithTopLevelMessage.

@Test
void checkStatusWithTopLevelMessage() throws ApiException {
    ApiCommand addRepositoriesCmd = addReposCmd();
    ApiCommand deployParcelsCmd = deployParcelsCmd();
    ApiCommand templateInstallCmd = templateInstallCmd(addRepositoriesCmd, deployParcelsCmd).resultMessage("IllegalArgumentException: Unknown configuration attribute 'process_autorestart_enabled'.");
    expectReadCommandForFailedCommands(templateInstallCmd);
    ClouderaManagerOperationFailedException ex = assertThrowsExact(ClouderaManagerOperationFailedException.class, () -> underTest.checkStatus(pollerObject));
    String expected = expectMessageForCommands(templateInstallCmd);
    assertEquals(expected, ex.getMessage());
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 8 with ClouderaManagerOperationFailedException

use of com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerTemplateInstallationChecker method handleTimeout.

@Override
public void handleTimeout(ClouderaManagerCommandPollerObject pollerObject) {
    String msg = "Installation of CDP with Cloudera Manager has timed out (command id: " + pollerObject.getId() + ").";
    try {
        CommandsResourceApi commandsResourceApi = clouderaManagerApiPojoFactory.getCommandsResourceApi(pollerObject.getApiClient());
        ApiCommand apiCommand = commandsResourceApi.readCommand(pollerObject.getId());
        fail(msg, apiCommand, commandsResourceApi, pollerObject.getStack().getType());
    } catch (ApiException e) {
        LOGGER.info("Cloudera Manager had run into a timeout, and we were unable to determine the failure reason", e);
    }
    throw new ClouderaManagerOperationFailedException(msg);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 9 with ClouderaManagerOperationFailedException

use of com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerTemplateInstallationChecker method fail.

private void fail(String messagePrefix, ApiCommand apiCommand, CommandsResourceApi commandsResourceApi, StackType stackType) {
    List<CommandDetails> failedCommands = ClouderaManagerCommandUtil.getFailedOrActiveCommands(apiCommand, commandsResourceApi);
    String msg = messagePrefix + "Installation of CDP with Cloudera Manager has failed. " + CommandDetailsFormatter.formatFailedCommands(failedCommands);
    LOGGER.debug("Top level command {}. Failed or active commands: {}", CommandDetails.fromApiCommand(apiCommand), failedCommands);
    if (stackType == StackType.DATALAKE) {
        for (CommandDetails failedCommand : failedCommands) {
            // has no added value, therefore we are just checking whether AuditDir related commands are failing or not.
            if (CLOUD_STORAGE_RELATED_COMMANDS.contains(failedCommand.getName()) && CommandDetails.CommandStatus.FAILED == failedCommand.getCommandStatus()) {
                throw new CloudStorageConfigurationFailedException(msg);
            }
        }
    }
    throw new ClouderaManagerOperationFailedException(msg);
}
Also used : ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) CommandDetails(com.sequenceiq.cloudbreak.cm.exception.CommandDetails) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException)

Example 10 with ClouderaManagerOperationFailedException

use of com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException in project cloudbreak by hortonworks.

the class AbstractClouderaManagerCommandCheckerTask method doStatusCheck.

protected boolean doStatusCheck(T pollerObject) throws ApiException {
    CommandsResourceApi commandsResourceApi = clouderaManagerApiPojoFactory.getCommandsResourceApi(pollerObject.getApiClient());
    ApiCommand apiCommand = commandsResourceApi.readCommand(pollerObject.getId());
    if (apiCommand.getActive()) {
        LOGGER.debug("Command [{}] with id [{}] is active, so it hasn't finished yet", getCommandName(), pollerObject.getId());
        return false;
    } else if (apiCommand.getSuccess()) {
        return true;
    } else {
        List<CommandDetails> commandDetails = ClouderaManagerCommandUtil.getFailedOrActiveCommands(apiCommand, commandsResourceApi);
        String message = CommandDetailsFormatter.formatFailedCommands(commandDetails);
        LOGGER.debug("Top level command {}. Failed or active commands: {}", CommandDetails.fromApiCommand(apiCommand), commandDetails);
        throw new ClouderaManagerOperationFailedException(message);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi) List(java.util.List)

Aggregations

ClouderaManagerOperationFailedException (com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException)10 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)8 Test (org.junit.jupiter.api.Test)6 CommandsResourceApi (com.cloudera.api.swagger.CommandsResourceApi)2 ApiException (com.cloudera.api.swagger.client.ApiException)2 ApiParcel (com.cloudera.api.swagger.model.ApiParcel)1 ApiParcelState (com.cloudera.api.swagger.model.ApiParcelState)1 CloudStorageConfigurationFailedException (com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException)1 CommandDetails (com.sequenceiq.cloudbreak.cm.exception.CommandDetails)1 List (java.util.List)1