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;
}
Aggregations