use of com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException in project cloudbreak by hortonworks.
the class LoggingAgentAutoRestartPatchService method isAffected.
@Override
public boolean isAffected(Stack stack) {
try {
boolean affected = false;
if (StackType.WORKLOAD.equals(stack.getType())) {
Image image = stackImageService.getCurrentImage(stack);
Map<String, String> packageVersions = image.getPackageVersions();
boolean hasCdpLoggingAgentPackageVersion = packageVersions.containsKey(ImagePackageVersion.CDP_LOGGING_AGENT.getKey());
if (hasCdpLoggingAgentPackageVersion && Version.parse(packageVersions.get(ImagePackageVersion.CDP_LOGGING_AGENT.getKey())).compareTo(affectedVersion) <= 0) {
affected = true;
} else if (!hasCdpLoggingAgentPackageVersion) {
affected = isAffectedByImageTimestamp(stack, image, dateAfterTimestamp, dateBeforeTimestamp);
}
}
return affected;
} catch (Exception e) {
LOGGER.warn("Image not found for stack " + stack.getResourceCrn(), e);
throw new CloudbreakRuntimeException("Image not found for stack " + stack.getResourceCrn(), e);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException in project cloudbreak by hortonworks.
the class LockedComponentService method isComponentsLocked.
public boolean isComponentsLocked(Stack stack, String targetImageId) {
try {
Image currentImage = componentConfigProviderService.getImage(stack.getId());
CloudbreakImageCatalogV3 imageCatalog = imageCatalogProvider.getImageCatalogV3(currentImage.getImageCatalogUrl());
com.sequenceiq.cloudbreak.cloud.model.catalog.Image currentCatalogImage = imageProvider.getCurrentImageFromCatalog(currentImage.getImageId(), imageCatalog);
com.sequenceiq.cloudbreak.cloud.model.catalog.Image targetCatalogImage = imageProvider.getCurrentImageFromCatalog(targetImageId, imageCatalog);
LOGGER.info("Determining that the stack {} component versions are the same on the current image {} and the target image {}", stack.getName(), currentCatalogImage.getUuid(), targetCatalogImage.getUuid());
return lockedComponentChecker.isUpgradePermitted(currentCatalogImage, targetCatalogImage, imageFilterParamsFactory.getStackRelatedParcels(stack));
} catch (Exception ex) {
String msg = "Exception during determining the lockComponents parameter.";
LOGGER.warn(msg, ex);
throw new CloudbreakRuntimeException(msg, ex);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException in project cloudbreak by hortonworks.
the class ArchiveInstanceMetaDataServiceTest method testArchiveWithExceptionWhenTransactionExecutionExceptionThrown.
@Test
void testArchiveWithExceptionWhenTransactionExecutionExceptionThrown() throws Exception {
StackView stack = new StackView();
stack.setResourceCrn(RESOURCE_CRN);
stack.setId(STACK_ID);
TransactionService.TransactionExecutionException exception = new TransactionService.TransactionExecutionException("Transaction failed", new CloudbreakRuntimeException(""));
when(transactionService.required(any(Supplier.class))).thenThrow(exception);
ArchiveInstanceMetaDataException actual = assertThrows(ArchiveInstanceMetaDataException.class, () -> underTest.archive(stack));
assertThat(actual.getMessage()).isEqualTo("Failed to archive the batch #0 of terminated instancemetadata for stack crn:env");
}
use of com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException in project cloudbreak by hortonworks.
the class ClusterManagerUpgradeService method upgradeClusterManager.
private void upgradeClusterManager(Stack stack) throws CloudbreakOrchestratorException {
Cluster cluster = stack.getCluster();
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig primaryGatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.getGateway() != null);
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
SaltConfig pillar = createSaltConfig(stack, cluster.getId(), primaryGatewayConfig);
Set<String> allNode = stackUtil.collectNodes(stack).stream().map(Node::getHostname).collect(Collectors.toSet());
try {
Set<Node> reachableNodes = stackUtil.collectAndCheckReachableNodes(stack, allNode);
hostOrchestrator.upgradeClusterManager(primaryGatewayConfig, gatewayFQDN, reachableNodes, pillar, exitCriteriaModel);
} catch (NodesUnreachableException e) {
String errorMessage = "Can not upgrade cluster manager because the configuration management service is not responding on these nodes: " + e.getUnreachableNodes();
LOGGER.error(errorMessage);
throw new CloudbreakRuntimeException(errorMessage, e);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException in project cloudbreak by hortonworks.
the class HostMetadataSetup method setupHostMetadata.
public void setupHostMetadata(Long stackId) {
try {
transactionService.required(() -> {
LOGGER.debug("Setting up host metadata for the cluster.");
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Set<InstanceMetaData> allInstanceMetadataByStackId = instanceMetaDataService.getNotDeletedAndNotZombieInstanceMetadataByStackId(stackId);
updateWithHostData(stack, allInstanceMetadataByStackId);
instanceMetaDataService.saveAll(allInstanceMetadataByStackId);
});
} catch (TransactionExecutionException e) {
throw new CloudbreakRuntimeException(e.getCause());
}
}
Aggregations