Search in sources :

Example 1 with HostGroupName

use of com.sequenceiq.cloudbreak.service.cluster.model.HostGroupName 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)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 HostGroupName (com.sequenceiq.cloudbreak.service.cluster.model.HostGroupName)1 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Collectors.toSet (java.util.stream.Collectors.toSet)1