Search in sources :

Example 1 with CloudStorageDiagnosticsParameters

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

the class CloudStorageValidationService method executeValidation.

private void executeValidation(Stack stack, List<GatewayConfig> allGateways, Set<Node> allNodes, DetailedEnvironmentResponse environment, ExitCriteriaModel exitCriteriaModel, Set<String> targetHostNames) throws CloudbreakOrchestratorException {
    CloudStorageDiagnosticsParameters cloudStorageParameters = diagnosticCloudStorageConverter.loggingResponseToCloudStorageDiagnosticsParameters(environment.getTelemetry().getLogging(), stack.getRegion());
    DiagnosticParameters parameters = new DiagnosticParameters();
    parameters.setRoot(DiagnosticParameters.TELEMETRY_ROOT);
    parameters.setCloudStorageDiagnosticsParameters(cloudStorageParameters);
    telemetryOrchestrator.validateCloudStorage(allGateways, allNodes, targetHostNames, parameters.toMap(), exitCriteriaModel);
}
Also used : CloudStorageDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CloudStorageDiagnosticsParameters) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters)

Example 2 with CloudStorageDiagnosticsParameters

use of com.sequenceiq.common.model.diagnostics.CloudStorageDiagnosticsParameters 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 3 with CloudStorageDiagnosticsParameters

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

the class DiagnosticsCollectionActions method diagnosticsUploadAction.

@Bean(name = "DIAGNOSTICS_UPLOAD_STATE")
public Action<?, ?> diagnosticsUploadAction() {
    return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            Long resourceId = payload.getResourceId();
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into DIAGNOSTICS_UPLOAD_STATE. resourceCrn: '{}'", resourceCrn);
            fireUploadEvent(resourceId, payload);
            DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionHandlerSelectors.UPLOAD_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).withHosts(payload.getHosts()).withHostGroups(payload.getHostGroups()).withExcludeHosts(payload.getExcludeHosts()).build();
            sendEvent(context, event);
        }

        private void fireUploadEvent(Long resourceId, DiagnosticsCollectionEvent payload) {
            DiagnosticParameters parameters = payload.getParameters();
            String message;
            switch(parameters.getDestination()) {
                case CLOUD_STORAGE:
                    String storageLocation = getStorageLocation(parameters);
                    message = "Upload location: " + storageLocation;
                    break;
                case ENG:
                    message = "Engineering will receive the logs.";
                    break;
                case SUPPORT:
                    if (StringUtils.isNotBlank(parameters.getIssue())) {
                        message = String.format("Diagnostics have been sent to support. " + "Case number: '%s' Description: '%s'", parameters.getIssue(), parameters.getDescription());
                    } else {
                        message = String.format("Diagnostics have been sent to support. " + "A ticket will be created for the diagnostics. Description: '%s'", parameters.getDescription());
                    }
                    break;
                default:
                    message = "Location for logs on each node: " + LOCAL_LOG_PATH;
                    break;
            }
            cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_DIAGNOSTICS_UPLOAD_RUNNING, List.of(message));
        }

        private String getStorageLocation(DiagnosticParameters parameters) {
            String storageLocation;
            CloudStorageDiagnosticsParameters csDiagnosticsParams = parameters.getCloudStorageDiagnosticsParameters();
            if (csDiagnosticsParams instanceof AwsDiagnosticParameters) {
                AwsDiagnosticParameters awsParameters = (AwsDiagnosticParameters) csDiagnosticsParams;
                storageLocation = "s3://" + Paths.get(awsParameters.getS3Bucket(), awsParameters.getS3Location()).toString();
            } else if (csDiagnosticsParams instanceof AzureDiagnosticParameters) {
                AzureDiagnosticParameters azureParameters = (AzureDiagnosticParameters) csDiagnosticsParams;
                storageLocation = "abfs://" + Paths.get(azureParameters.getAdlsv2StorageContainer(), azureParameters.getAdlsv2StorageLocation()).toString();
            } else {
                GcsDiagnosticsParameters gcsParameters = (GcsDiagnosticsParameters) csDiagnosticsParams;
                storageLocation = "gcs://" + Paths.get(gcsParameters.getBucket(), gcsParameters.getGcsLocation()).toString();
            }
            return storageLocation;
        }
    };
}
Also used : AwsDiagnosticParameters(com.sequenceiq.common.model.diagnostics.AwsDiagnosticParameters) CloudStorageDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CloudStorageDiagnosticsParameters) CommonContext(com.sequenceiq.flow.core.CommonContext) AwsDiagnosticParameters(com.sequenceiq.common.model.diagnostics.AwsDiagnosticParameters) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) AzureDiagnosticParameters(com.sequenceiq.common.model.diagnostics.AzureDiagnosticParameters) AzureDiagnosticParameters(com.sequenceiq.common.model.diagnostics.AzureDiagnosticParameters) GcsDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.GcsDiagnosticsParameters) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

CloudStorageDiagnosticsParameters (com.sequenceiq.common.model.diagnostics.CloudStorageDiagnosticsParameters)3 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)3 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 AwsDiagnosticParameters (com.sequenceiq.common.model.diagnostics.AwsDiagnosticParameters)1 AzureDiagnosticParameters (com.sequenceiq.common.model.diagnostics.AzureDiagnosticParameters)1 GcsDiagnosticsParameters (com.sequenceiq.common.model.diagnostics.GcsDiagnosticsParameters)1 CommonContext (com.sequenceiq.flow.core.CommonContext)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1