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);
}
}
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);
}
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;
}
}
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;
}
}
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);
}
}
Aggregations