Search in sources :

Example 91 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class CmVersionQueryServiceTest method testWhenServerHasMultiplePackageVersionsThenValidateConsistencyShouldFail.

@Test
void testWhenServerHasMultiplePackageVersionsThenValidateConsistencyShouldFail() {
    Map<String, List<PackageInfo>> hostPackageMap = Maps.newHashMap();
    hostPackageMap.put(HOST_1, getPackageInfoList(true));
    hostPackageMap.put(HOST_2, getPackageInfoList(false));
    CloudbreakServiceException exception = assertThrows(CloudbreakServiceException.class, () -> underTest.checkCmPackageInfoConsistency(hostPackageMap));
    Assertions.assertEquals("Error during sync! The following package(s) has multiple versions present on the machines. " + "Package: [PackageInfo{name='cloudera-manager-server', version='2', buildNumber='2000'}, " + "PackageInfo{name='cloudera-manager-server', version='1', buildNumber='1000'}]", exception.getMessage());
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 92 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class AbstractAction method execute.

@Override
public void execute(StateContext<S, E> context) {
    FlowParameters flowParameters = (FlowParameters) context.getMessageHeader(MessageFactory.HEADERS.FLOW_PARAMETERS.name());
    ThreadBasedUserCrnProvider.doAs(flowParameters.getFlowTriggerUserCrn(), () -> {
        MDCBuilder.addFlowId(flowParameters.getFlowId());
        P payload = convertPayload(context.getMessageHeader(MessageFactory.HEADERS.DATA.name()));
        C flowContext = null;
        try {
            Map<Object, Object> variables = context.getExtendedState().getVariables();
            prepareExecution(payload, variables);
            String flowStateName = String.valueOf(variables.get(FLOW_STATE_NAME));
            Span activeSpan = tracer.activeSpan();
            String operationName = context.getEvent().name();
            SpanContext spanContext = flowParameters.getSpanContext();
            if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) {
                LOGGER.debug("Reusing existing span. {}", activeSpan.context());
                flowContext = createFlowContext(flowParameters, context, payload);
                executeAction(context, payload, flowContext, variables, flowStateName);
            } else {
                Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowParameters.getFlowId(), null, flowParameters.getFlowTriggerUserCrn());
                spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span);
                flowParameters.setSpanContext(spanContext);
                try (Scope ignored = tracer.activateSpan(span)) {
                    flowContext = createFlowContext(flowParameters, context, payload);
                    executeAction(context, payload, flowContext, variables, flowStateName);
                } finally {
                    span.finish();
                }
            }
        } catch (Exception ex) {
            LOGGER.error("Error during execution of " + getClass().getName(), ex);
            if (failureEvent != null) {
                sendEvent(flowParameters, failureEvent.event(), getFailurePayload(payload, Optional.ofNullable(flowContext), ex), Map.of());
            } else {
                LOGGER.error("Missing error handling for " + getClass().getName());
                throw new CloudbreakServiceException("Missing error handling for " + getClass().getName());
            }
        }
    });
}
Also used : SpanContext(io.opentracing.SpanContext) Scope(io.opentracing.Scope) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Span(io.opentracing.Span) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 93 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverter method convertTelemetryComponent.

private void convertTelemetryComponent(StackV4Response response, Stack source) {
    TelemetryResponse telemetryResponse = null;
    try {
        Telemetry telemetry = componentConfigProviderService.getTelemetry(source.getId());
        telemetryResponse = telemetryConverter.convert(telemetry);
    } catch (CloudbreakServiceException exc) {
        LOGGER.debug(exc.getMessage());
    }
    response.setTelemetry(telemetryResponse);
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry)

Example 94 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverter method convert.

public TemplatePreparationObject convert(StackV4Request source) {
    try {
        CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
        User user = userService.getOrCreate(cloudbreakUser);
        Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
        DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
        Credential credential = getCredential(source, environment);
        LdapView ldapConfig = getLdapConfig(source, environment);
        BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
        Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
        Blueprint blueprint = getBlueprint(source, workspace);
        Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
        Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
        BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
        Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
        GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
        String gatewaySignKey = null;
        if (gateway != null) {
            gatewaySignKey = gateway.getSignKey();
        }
        String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
        VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
        Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
        decorateBuilderWithPlacement(source, builder);
        decorateBuilderWithAccountMapping(source, environment, credential, builder);
        decorateBuilderWithProductDetails(source, builder);
        decorateDatalakeView(source, builder);
        return builder.build();
    } catch (BlueprintProcessingException | IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.template.BlueprintProcessingException) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) IOException(java.io.IOException) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 95 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ClusterService method cleanupCluster.

public void cleanupCluster(final Cluster cluster) {
    if (StringUtils.isEmpty(cluster.getClusterManagerIp())) {
        LOGGER.debug("Cluster server IP was not set before, cleanup cluster operation can be skipped.");
    } else {
        Stack stack = cluster.getStack();
        if (stack != null) {
            try {
                Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
                clusterApiConnectors.getConnector(stack).clusterModificationService().cleanupCluster(telemetry);
                altusMachineUserService.clearFluentMachineUser(stack, telemetry);
            } catch (CloudbreakServiceException se) {
                LOGGER.error("Cluster specific cleanup failed during obtaining telemetry component.", se);
            } catch (CloudbreakException e) {
                LOGGER.error("Cluster specific cleanup failed.", e);
            }
        }
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)142 Test (org.junit.jupiter.api.Test)25 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 List (java.util.List)20 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)18 IOException (java.io.IOException)18 Map (java.util.Map)18 ApiException (com.cloudera.api.swagger.client.ApiException)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)15 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)14 LoggerFactory (org.slf4j.LoggerFactory)14 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)12 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)12 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)12 Optional (java.util.Optional)12 Set (java.util.Set)12