@Test public void shouldNotAllowRepairWhenNodeIsStoppedInNotSelectedInstanceGroup() { HostGroup hostGroup1 = new HostGroup(); hostGroup1.setName("hostGroup1"); hostGroup1.setRecoveryMode(RecoveryMode.MANUAL); InstanceMetaData host1 = getHost("host1", hostGroup1.getName(), InstanceStatus.SERVICES_UNHEALTHY, InstanceGroupType.CORE); hostGroup1.setInstanceGroup(host1.getInstanceGroup()); HostGroup hostGroup2 = new HostGroup(); hostGroup2.setName("hostGroup2"); hostGroup2.setRecoveryMode(RecoveryMode.MANUAL); InstanceMetaData host2 = getHost("host2", hostGroup2.getName(), InstanceStatus.STOPPED, InstanceGroupType.CORE); hostGroup2.setInstanceGroup(host2.getInstanceGroup()); when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack); when(stack.getInstanceMetaDataAsList()).thenReturn(List.of(host1, host2)); BadRequestException exception = assertThrows(BadRequestException.class, () -> { underTest.repairHostGroups(1L, Set.of("hostGroup1"), false, false); }); String expectedErrorMessage = "Action cannot be performed because there are stopped nodes in the cluster. Please select them for repair or start the stopped nodes."; assertEquals(expectedErrorMessage, exception.getMessage()); verifyEventArguments(CLUSTER_MANUALRECOVERY_COULD_NOT_START, expectedErrorMessage); verifyNoInteractions(stackUpdater); }
public FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.HOST_GROUP, stackId, hostGroups, false); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, hostGroups); }
ClusterRepairService { public FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.HOST_GROUP, stackId, hostGroups, false); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, hostGroups); } }
ClusterRepairService { public FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.HOST_GROUP, stackId, hostGroups, false); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, hostGroups); }  }
ClusterRepairService { public FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.HOST_GROUP, stackId, hostGroups, false); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, hostGroups); }  FlowIdentifier repairAll(Long stackId); FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices); FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices); Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairWithDryRun(Long stackId); }
ClusterRepairService { public FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.HOST_GROUP, stackId, hostGroups, false); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, hostGroups); }  FlowIdentifier repairAll(Long stackId); FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices); FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices); Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairWithDryRun(Long stackId);  }