Search in sources :

Example 41 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class FinalizeClusterInstallHandlerService method finalizeClusterInstall.

public void finalizeClusterInstall(Set<InstanceMetaData> instances, Cluster cluster) {
    LOGGER.info("Cluster created successfully. Cluster name: {}", cluster.getName());
    for (InstanceMetaData instance : instances) {
        instance.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    }
    instanceMetaDataService.saveAll(instances);
    Long now = new Date().getTime();
    cluster.setCreationFinished(now);
    cluster.setUpSince(now);
    clusterService.updateCluster(cluster);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Date(java.util.Date)

Example 42 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class InstanceMetadataUpdater method collectPackagesWithMultipleVersions.

public List<String> collectPackagesWithMultipleVersions(Collection<InstanceMetaData> instanceMetadataList) {
    try {
        Multimap<String, String> pkgVersionsMMap = HashMultimap.create();
        for (InstanceMetaData im : instanceMetadataList) {
            Image image = im.getImage().get(Image.class);
            for (Entry<String, String> packageEntry : image.getPackageVersions().entrySet()) {
                pkgVersionsMMap.put(packageEntry.getKey(), packageEntry.getValue());
            }
        }
        List<String> packagesWithMultipleVersions = new ArrayList<>();
        for (String pkg : pkgVersionsMMap.keySet()) {
            if (pkgVersionsMMap.get(pkg).size() > 1) {
                packagesWithMultipleVersions.add(pkg);
            }
        }
        if (!packagesWithMultipleVersions.isEmpty()) {
            LOGGER.debug("Packages unfortunately do have multiple versions: {}", pkgVersionsMMap);
        }
        return packagesWithMultipleVersions;
    } catch (IOException ex) {
        LOGGER.warn("Cannot collect package versions from hosts", ex);
        return Collections.emptyList();
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 43 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class InstanceMetadataUpdater method updateInstanceMetaDataIfVersionQueryFailed.

private List<String> updateInstanceMetaDataIfVersionQueryFailed(Map<String, Map<String, String>> packageVersionsByNameByHost, Stack stack) throws IOException {
    Set<InstanceMetaData> instanceMetaDataSet = stack.getNotDeletedAndNotZombieInstanceMetaDataSet();
    List<String> failedVersionQueriesByHost = Lists.newArrayList();
    for (InstanceMetaData im : instanceMetaDataSet) {
        Map<String, String> packageVersionsOnHost = packageVersionsByNameByHost.get(im.getDiscoveryFQDN());
        if (CollectionUtils.isEmpty(packageVersionsOnHost)) {
            failedVersionQueriesByHost.add(im.getDiscoveryFQDN());
            Image image = im.getImage().get(Image.class);
            image.getPackageVersions().clear();
            im.setImage(new Json(image));
            im.setInstanceStatus(InstanceStatus.SERVICES_UNHEALTHY);
            im.setStatusReason("Version query is failed on host");
            instanceMetaDataService.save(im);
        }
    }
    return failedVersionQueriesByHost;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 44 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class ClusterRepairService method validateRepair.

public Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> validateRepair(ManualClusterRepairMode repairMode, Long stackId, Set<String> selectedParts, boolean deleteVolumes) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    boolean reattach = !deleteVolumes;
    Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult;
    List<String> stoppedInstanceIds = getStoppedNotSelectedInstanceIds(stack, repairMode, selectedParts);
    if (!freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())) {
        repairStartResult = Result.error(RepairValidation.of("Action cannot be performed because the FreeIPA isn't available. Please check the FreeIPA state."));
    } else if (!environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))) {
        repairStartResult = Result.error(RepairValidation.of("Action cannot be performed because the Environment isn't available. Please check the Environment state."));
    } else if (!stoppedInstanceIds.isEmpty()) {
        repairStartResult = Result.error(RepairValidation.of("Action cannot be performed because there are stopped nodes in the cluster. " + "Stopped nodes: [" + String.join(", ", stoppedInstanceIds) + "]. " + "Please select them for repair or start the stopped nodes."));
    } else if (!isReattachSupportedOnProvider(stack, reattach)) {
        repairStartResult = Result.error(RepairValidation.of(String.format("Volume reattach currently not supported on %s platform!", stack.getPlatformVariant())));
    } else if (hasNotAvailableDatabase(stack)) {
        repairStartResult = Result.error(RepairValidation.of(String.format("Database %s is not in AVAILABLE status, could not start repair.", stack.getCluster().getDatabaseServerCrn())));
    } else if (isHAClusterAndRepairNotAllowed(stack)) {
        repairStartResult = Result.error(RepairValidation.of("Repair is not supported when the cluster uses cluster proxy and has multiple gateway nodes. This will be fixed in future releases."));
    } else if (isAnyGWUnhealthyAndItIsNotSelected(repairMode, selectedParts, stack)) {
        repairStartResult = Result.error(RepairValidation.of("Gateway node is unhealthy, it must be repaired first."));
    } else {
        Map<HostGroupName, Set<InstanceMetaData>> repairableNodes = selectRepairableNodes(getInstanceSelectors(repairMode, selectedParts), stack);
        if (repairableNodes.isEmpty()) {
            repairStartResult = Result.error(RepairValidation.of("Repairable node list is empty. Please check node statuses and try again."));
        } else {
            RepairValidation validationBySelectedNodes = validateSelectedNodes(stack, repairableNodes, reattach);
            if (!validationBySelectedNodes.getValidationErrors().isEmpty()) {
                repairStartResult = Result.error(validationBySelectedNodes);
            } else {
                setStackStatusAndMarkDeletableVolumes(repairMode, deleteVolumes, stack, repairableNodes);
                repairStartResult = Result.success(repairableNodes);
            }
        }
    }
    return repairStartResult;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) HostGroupName(com.sequenceiq.cloudbreak.service.cluster.model.HostGroupName) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 45 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class RdsRecoverySetupService method createOrchestratorGrainRunnerParams.

private OrchestratorGrainRunnerParams createOrchestratorGrainRunnerParams(Stack stack, Cluster cluster, Set<Node> nodes, GrainOperation grainOperation) {
    OrchestratorGrainRunnerParams grainRunnerParams = new OrchestratorGrainRunnerParams();
    InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
    grainRunnerParams.setPrimaryGatewayConfig(gatewayConfigService.getGatewayConfig(stack, gatewayInstance, stack.getCluster().hasGateway()));
    Set<String> targetHostNames = gatewayInstance.getDiscoveryFQDN() != null ? Set.of(gatewayInstance.getDiscoveryFQDN()) : Set.of();
    grainRunnerParams.setTargetHostNames(targetHostNames);
    grainRunnerParams.setAllNodes(nodes);
    grainRunnerParams.setExitCriteriaModel(ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stack.getId(), cluster.getId()));
    grainRunnerParams.setKey(ROLES);
    grainRunnerParams.setValue(RECOVER);
    grainRunnerParams.setGrainOperation(grainOperation);
    return grainRunnerParams;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) OrchestratorGrainRunnerParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorGrainRunnerParams)

Aggregations

InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)415 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)165 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)152 Test (org.junit.jupiter.api.Test)143 Map (java.util.Map)92 HashSet (java.util.HashSet)90 Set (java.util.Set)86 List (java.util.List)84 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)77 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)73 Collectors (java.util.stream.Collectors)71 ArrayList (java.util.ArrayList)62 Test (org.junit.Test)60 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)57 Optional (java.util.Optional)52 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)48 Inject (javax.inject.Inject)47 Logger (org.slf4j.Logger)47 LoggerFactory (org.slf4j.LoggerFactory)47 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)45