Search in sources :

Example 1 with ClusterDeletionBasedExitCriteriaModel

use of com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel in project cloudbreak by hortonworks.

the class CmDiagnosticsFlowService method executeCmDiagnosticOperation.

private void executeCmDiagnosticOperation(Long stackId, String operation, Set<String> excludeHosts, CmDiagnosticsFlowOperation func) throws CloudbreakOrchestratorFailedException {
    LOGGER.debug("CM Diagnostics {} will be called only on the primary gateway address", operation);
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
    String primaryGatewayIp = gatewayConfigService.getPrimaryGatewayIp(stack);
    Set<String> hosts = Set.of(primaryGatewayIp);
    OrchestratorMetadataFilter filter = OrchestratorMetadataFilter.Builder.newBuilder().includeHosts(hosts).exlcudeHosts(excludeHosts).build();
    Set<Node> filteredNodes = filter.apply(stack.getAllNodes());
    ClusterDeletionBasedExitCriteriaModel exitModel = new ClusterDeletionBasedExitCriteriaModel(stackId, stack.getCluster().getId());
    if (filteredNodes.isEmpty()) {
        LOGGER.debug("CM Diagnostics {} has been skipped. (no target minions)", operation);
    } else {
        LOGGER.debug("CM Diagnostics operation '{}' has been started.", operation);
        func.apply(gatewayConfigs, filteredNodes, exitModel);
        LOGGER.debug("CM Diagnostics operation '{}' has been finished.", operation);
    }
}
Also used : OrchestratorMetadataFilter(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 2 with ClusterDeletionBasedExitCriteriaModel

use of com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel in project cloudbreak by hortonworks.

the class OrchestratorService method getOrchestratorMetadata.

@Override
public OrchestratorMetadata getOrchestratorMetadata(Long stackId) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
    ClusterDeletionBasedExitCriteriaModel exitModel = new ClusterDeletionBasedExitCriteriaModel(stackId, stack.getCluster().getId());
    return new OrchestratorMetadata(gatewayConfigs, stack.getAllNodes(), exitModel, stack);
}
Also used : OrchestratorMetadata(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadata) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 3 with ClusterDeletionBasedExitCriteriaModel

use of com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel in project cloudbreak by hortonworks.

the class LoggingAgentAutoRestartPatchService method doApply.

@Override
boolean doApply(Stack stack) throws ExistingStackPatchApplyException {
    if (isPrimaryGatewayReachable(stack)) {
        try {
            byte[] currentSaltState = getCurrentSaltStateStack(stack);
            List<String> saltStateDefinitions = Arrays.asList("salt-common", "salt");
            List<String> loggingAgentSaltStateDef = List.of("/salt/fluent");
            byte[] fluentSaltStateConfig = compressUtil.generateCompressedOutputFromFolders(saltStateDefinitions, loggingAgentSaltStateDef);
            boolean loggingAgentContentMatches = compressUtil.compareCompressedContent(currentSaltState, fluentSaltStateConfig, loggingAgentSaltStateDef);
            if (!loggingAgentContentMatches) {
                Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
                List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
                ClusterDeletionBasedExitCriteriaModel exitModel = ClusterDeletionBasedExitCriteriaModel.nonCancellableModel();
                Set<Node> availableNodes = getAvailableNodes(instanceMetaDataSet, gatewayConfigs, exitModel);
                if (CollectionUtils.isEmpty(availableNodes)) {
                    LOGGER.info("Not found any available nodes for patch, stack: " + stack.getName());
                    return false;
                } else {
                    getTelemetryOrchestrator().executeLoggingAgentDiagnostics(fluentSaltStateConfig, gatewayConfigs, availableNodes, exitModel);
                    byte[] newFullSaltState = compressUtil.updateCompressedOutputFolders(saltStateDefinitions, loggingAgentSaltStateDef, currentSaltState);
                    clusterBootstrapper.updateSaltComponent(stack, newFullSaltState);
                    LOGGER.debug("Logging agent partial salt refresh and diagnostics successfully finished for stack {}", stack.getName());
                    return true;
                }
            } else {
                LOGGER.debug("Logging agent partial salt refresh and diagnostics is not required for stack {}", stack.getName());
                return true;
            }
        } catch (ExistingStackPatchApplyException e) {
            throw e;
        } catch (Exception e) {
            throw new ExistingStackPatchApplyException(e.getMessage(), e);
        }
    } else {
        LOGGER.info("Salt partial update cannot run, because primary gateway is unreachable of stack: " + stack.getResourceCrn());
        return false;
    }
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 4 with ClusterDeletionBasedExitCriteriaModel

use of com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel in project cloudbreak by hortonworks.

the class MeteringAzureMetadataPatchService method upgradeMeteringOnNodes.

private boolean upgradeMeteringOnNodes(Stack stack) throws ExistingStackPatchApplyException, IOException, CloudbreakOrchestratorFailedException {
    byte[] currentSaltState = getCurrentSaltStateStack(stack);
    List<String> saltStateDefinitions = Arrays.asList("salt-common", "salt");
    List<String> meteringSaltStateDef = List.of("/salt/metering");
    byte[] meteringSaltStateConfig = compressUtil.generateCompressedOutputFromFolders(saltStateDefinitions, meteringSaltStateDef);
    boolean meteringContentMatches = compressUtil.compareCompressedContent(currentSaltState, meteringSaltStateConfig, meteringSaltStateDef);
    if (!meteringContentMatches) {
        Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
        List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
        ClusterDeletionBasedExitCriteriaModel exitModel = ClusterDeletionBasedExitCriteriaModel.nonCancellableModel();
        getTelemetryOrchestrator().updateMeteringSaltDefinition(meteringSaltStateConfig, gatewayConfigs, exitModel);
        Set<Node> availableNodes = getAvailableNodes(instanceMetaDataSet, gatewayConfigs, exitModel);
        if (CollectionUtils.isEmpty(availableNodes)) {
            LOGGER.info("Not found any available nodes for patch, stack: " + stack.getName());
            return false;
        } else {
            getTelemetryOrchestrator().upgradeMetering(gatewayConfigs, availableNodes, exitModel, meteringAzureMetadataPatchConfig.getDateBefore(), meteringAzureMetadataPatchConfig.getCustomRpmUrl());
            byte[] newFullSaltState = compressUtil.updateCompressedOutputFolders(saltStateDefinitions, meteringSaltStateDef, currentSaltState);
            clusterBootstrapper.updateSaltComponent(stack, newFullSaltState);
            LOGGER.debug("Metering partial salt refresh successfully finished for stack {}", stack.getName());
            return true;
        }
    } else {
        LOGGER.debug("Metering partial salt refresh is not required for stack {}", stack.getName());
        return true;
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 5 with ClusterDeletionBasedExitCriteriaModel

use of com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel in project cloudbreak by hortonworks.

the class CloudStorageValidationService method validateCloudStorage.

public void validateCloudStorage(Long stackId) throws CloudbreakOrchestratorException {
    Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
    String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
    if (!entitlementService.cloudStorageValidationOnVmEnabled(accountId)) {
        LOGGER.info("Cloud storage validation on VM entitlement is missing, not validating cloud storage on VM.");
        return;
    }
    DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
    if (environment.isCloudStorageLoggingEnabled()) {
        ExitCriteriaModel exitCriteriaModel = new ClusterDeletionBasedExitCriteriaModel(stack.getId(), stack.getCluster().getId());
        List<GatewayConfig> allGateways = gatewayConfigService.getAllGatewayConfigs(stack);
        Set<Node> allNodes = stackUtil.collectNodes(stack);
        runIdBrokerValidation(stack, allGateways, allNodes, environment, exitCriteriaModel);
        runRandomHostValidation(stack, allGateways, allNodes, environment, exitCriteriaModel);
    }
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

ClusterDeletionBasedExitCriteriaModel (com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel)6 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)5 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)2 OrchestratorStateParams (com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateParams)1 OrchestratorMetadata (com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadata)1 OrchestratorMetadataFilter (com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter)1 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)1 CloudbreakRuntimeException (com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1