Search in sources :

Example 6 with CloudbreakRuntimeException

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);
    }
}
Also used : CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException)

Example 7 with CloudbreakRuntimeException

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);
    }
}
Also used : CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException)

Example 8 with CloudbreakRuntimeException

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");
}
Also used : TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) Supplier(java.util.function.Supplier) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Test(org.junit.jupiter.api.Test)

Example 9 with CloudbreakRuntimeException

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);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 10 with CloudbreakRuntimeException

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());
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

CloudbreakRuntimeException (com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException)10 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)4 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)3 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)2 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)2 Collection (java.util.Collection)2 Strings (com.google.common.base.Strings)1 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)1 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)1 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)1