Search in sources :

Example 31 with DiagnosticParameters

use of com.sequenceiq.common.model.diagnostics.DiagnosticParameters in project cloudbreak by hortonworks.

the class FreeIpaCloudStorageValidationService method validateCloudStorage.

private void validateCloudStorage(Stack stack, List<GatewayConfig> allGateways, Set<Node> allNodes, StackBasedExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorFailedException {
    try {
        if (stack.getTelemetry() != null && stack.getTelemetry().isCloudStorageLoggingEnabled()) {
            Set<String> targetHostNames = allNodes.stream().map(Node::getHostname).limit(1).collect(Collectors.toSet());
            CloudStorageDiagnosticsParameters cloudStorageParameters = diagnosticCloudStorageConverter.loggingToCloudStorageDiagnosticsParameters(stack.getTelemetry().getLogging(), stack.getRegion());
            DiagnosticParameters parameters = new DiagnosticParameters();
            parameters.setRoot(DiagnosticParameters.TELEMETRY_ROOT);
            parameters.setCloudStorageDiagnosticsParameters(cloudStorageParameters);
            telemetryOrchestrator.validateCloudStorage(allGateways, allNodes, targetHostNames, parameters.toMap(), exitCriteriaModel);
        }
    } catch (CloudbreakOrchestratorException e) {
        String errorMessage = getErrorMessage(stack, "logging");
        LOGGER.error(errorMessage, e);
        throw new CloudbreakOrchestratorFailedException(errorMessage, e);
    }
}
Also used : CloudStorageDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CloudStorageDiagnosticsParameters) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters)

Example 32 with DiagnosticParameters

use of com.sequenceiq.common.model.diagnostics.DiagnosticParameters in project cloudbreak by hortonworks.

the class DiagnosticsService method startDiagnosticsCollection.

public FlowIdentifier startDiagnosticsCollection(DiagnosticsCollectionRequest request, String accountId, String userCrn) {
    Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(request.getEnvironmentCrn(), accountId);
    diagnosticsCollectionValidator.validate(request, stack);
    LOGGER.debug("Starting diagnostics collection for FreeIpa. Crn: '{}'", stack.getResourceCrn());
    boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(stack.getAccountId());
    String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(stack.getTelemetry().getDatabusEndpoint(), useDbusCnameEndpoint);
    DiagnosticParameters parameters = diagnosticsDataToParameterConverter.convert(request, stack.getTelemetry(), FREEIPA_CLUSTER_TYPE, stack.getAppVersion(), stack.getAccountId(), stack.getRegion(), databusEndpoint);
    DiagnosticsCollectionEvent diagnosticsCollectionEvent = DiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(DiagnosticsCollectionStateSelectors.START_DIAGNOSTICS_SALT_VALIDATION_EVENT.selector()).withParameters(parameters).build();
    return flowManager.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
Also used : Promise(reactor.rx.Promise) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 33 with DiagnosticParameters

use of com.sequenceiq.common.model.diagnostics.DiagnosticParameters in project cloudbreak by hortonworks.

the class DiagnosticsUpgradeTelemetryHandlerTest method testDoAccept.

@Test
public void testDoAccept() throws CloudbreakOrchestratorFailedException {
    // GIVEN
    doNothing().when(telemetryUpgradeService).upgradeTelemetryComponent(anyLong(), any(), any());
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPGRADE_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(telemetryUpgradeService, times(1)).upgradeTelemetryComponent(anyLong(), any(), any());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Test(org.junit.jupiter.api.Test)

Example 34 with DiagnosticParameters

use of com.sequenceiq.common.model.diagnostics.DiagnosticParameters in project cloudbreak by hortonworks.

the class DiagnosticsUpgradeTelemetryHandlerTest method testFailureEvent.

@Test
public void testFailureEvent() {
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPGRADE_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    Selectable result = underTest.defaultFailureEvent(STACK_ID, new IllegalArgumentException("ex"), new Event<>(event));
    assertEquals(FAILED_DIAGNOSTICS_COLLECTION_EVENT.selector(), result.selector());
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Test(org.junit.jupiter.api.Test)

Example 35 with DiagnosticParameters

use of com.sequenceiq.common.model.diagnostics.DiagnosticParameters in project cloudbreak by hortonworks.

the class DiagnosticsUploadHandlerTest method testDoAccept.

@Test
public void testDoAccept() throws CloudbreakOrchestratorFailedException {
    // GIVEN
    doNothing().when(diagnosticsOperationsService).upload(anyLong(), any());
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPLOAD_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(diagnosticsOperationsService, times(1)).upload(anyLong(), any());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Test(org.junit.jupiter.api.Test)

Aggregations

DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)97 Test (org.junit.jupiter.api.Test)67 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)47 DiagnosticsCollectionEvent (com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)46 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)45 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23 Event (reactor.bus.Event)23 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)19 DiagnosticsFlowException (com.sequenceiq.cloudbreak.core.flow2.diagnostics.DiagnosticsFlowException)11 DiagnosticsFlowException (com.sequenceiq.freeipa.flow.freeipa.diagnostics.DiagnosticsFlowException)10 DataBusCredential (com.sequenceiq.common.api.telemetry.model.DataBusCredential)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 CloudStorageDiagnosticsParameters (com.sequenceiq.common.model.diagnostics.CloudStorageDiagnosticsParameters)3 CommonContext (com.sequenceiq.flow.core.CommonContext)3 Map (java.util.Map)3 Bean (org.springframework.context.annotation.Bean)3 OrchestratorMetadataFilter (com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter)2 AwsDiagnosticParameters (com.sequenceiq.common.model.diagnostics.AwsDiagnosticParameters)2 AzureDiagnosticParameters (com.sequenceiq.common.model.diagnostics.AzureDiagnosticParameters)2 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)2