use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner in project cloudbreak by hortonworks.
the class SaltOrchestrator method validateCloudStorageBackup.
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
@Override
public void validateCloudStorageBackup(GatewayConfig primaryGateway, List<GatewayConfig> allGatewayConfigs, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
Set<String> targetHostnames = allNodes.stream().map(Node::getHostname).collect(Collectors.toSet());
try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
runValidation(sc, new StateAllRunner(targetHostnames, allNodes, "validation/cloud-storage-backup"), exitCriteriaModel);
LOGGER.debug("Completed validating cloud storage");
} catch (CloudbreakOrchestratorException e) {
LOGGER.warn("CloudbreakOrchestratorException occurred during cloud storage validation", e);
throw e;
} catch (ExecutionException e) {
LOGGER.warn("Error occurred during cloud storage validation", e);
if (e.getCause() instanceof CloudbreakOrchestratorFailedException) {
throw (CloudbreakOrchestratorFailedException) e.getCause();
}
throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
} catch (Exception e) {
LOGGER.warn("Error occurred during cloud storage validation", e);
throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner in project cloudbreak by hortonworks.
the class SaltOrchestrator method formatAndMountDisksOnNodes.
@Override
@Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5)
public Map<String, Map<String, String>> formatAndMountDisksOnNodes(OrchestratorAware stack, List<GatewayConfig> allGateway, Set<Node> nodesWithDiskData, Set<Node> allNodes, ExitCriteriaModel exitModel, String platformVariant) throws CloudbreakOrchestratorFailedException {
GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(allGateway);
Set<String> gatewayTargetIpAddresses = getGatewayPrivateIps(allGateway);
Target<String> allHosts = new HostList(nodesWithDiskData.stream().map(Node::getHostname).collect(Collectors.toSet()));
try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
saveHostsPillar(stack, exitModel, gatewayTargetIpAddresses, sc);
Callable<Boolean> saltPillarRunner;
Map<String, String> dataVolumeMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getDataVolumes()));
Map<String, String> serialIdMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getSerialIds()));
Map<String, String> fstabMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getFstab()));
Map<String, String> temporaryStorageMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getTemporaryStorage().name()));
Map<String, Integer> dataBaseVolumeIndexMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getDatabaseVolumeIndex()));
Map<String, Object> hostnameDiskMountMap = nodesWithDiskData.stream().map(Node::getHostname).collect(Collectors.toMap(hn -> hn, hn -> Map.of("attached_volume_name_list", dataVolumeMap.getOrDefault(hn, ""), "attached_volume_serial_list", serialIdMap.getOrDefault(hn, ""), "cloud_platform", platformVariant, "previous_fstab", fstabMap.getOrDefault(hn, ""), "database_volume_index", dataBaseVolumeIndexMap.getOrDefault(hn, -1), "temporary_storage", temporaryStorageMap.getOrDefault(hn, TemporaryStorage.ATTACHED_VOLUMES.name()))));
SaltPillarProperties mounDiskProperties = new SaltPillarProperties("/mount/disk.sls", Collections.singletonMap("mount_data", hostnameDiskMountMap));
OrchestratorBootstrap pillarSave = PillarSave.createCustomPillar(sc, gatewayTargetIpAddresses, mounDiskProperties);
saltPillarRunner = saltRunner.runner(pillarSave, exitCriteria, exitModel);
saltPillarRunner.call();
saltCommandRunner.runModifyGrainCommand(sc, new GrainAddRunner(hostnameDiskMountMap.keySet(), allNodes, "mount_disks"), exitModel, exitCriteria);
StateAllRunner stateAllRunner = new StateAllRunner(gatewayTargetIpAddresses, allNodes, "disks.format-and-mount");
OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateAllRunner);
Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitModel);
saltJobRunBootstrapRunner.call();
Map<String, String> uuidResponse = SaltStates.getUuidList(sc);
saltCommandRunner.runModifyGrainCommand(sc, new GrainRemoveRunner(hostnameDiskMountMap.keySet(), allNodes, "mount_disks"), exitModel, exitCriteria);
Map<String, String> fstabResponse = SaltStates.runCommandOnHosts(retry, sc, allHosts, "cat /etc/fstab");
return nodesWithDiskData.stream().map(node -> {
String fstab = fstabResponse.getOrDefault(node.getHostname(), "");
String uuidList = uuidResponse.getOrDefault(node.getHostname(), "");
return new SimpleImmutableEntry<>(node.getHostname(), Map.of("uuids", uuidList, "fstab", fstab));
}).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
} catch (Exception e) {
LOGGER.info("Error occurred during the salt bootstrap", e);
throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner in project cloudbreak by hortonworks.
the class SaltTelemetryOrchestrator method installAndStartMonitoring.
@Override
public void installAndStartMonitoring(List<GatewayConfig> allGateways, Set<Node> nodes, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorFailedException {
GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(allGateways);
Set<String> serverHostname = Sets.newHashSet(primaryGateway.getHostname());
try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
StateAllRunner stateAllJobRunner = new StateAllRunner(serverHostname, nodes, MONITORING_INIT);
OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateAllJobRunner);
Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitModel);
saltJobRunBootstrapRunner.call();
} catch (Exception e) {
LOGGER.info("Error occurred during cluster monitoring start", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
Aggregations