use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method createHealthDetails.
private HealthDetailsFreeIpaResponse createHealthDetails(InstanceStatus status1, InstanceStatus status2) {
HealthDetailsFreeIpaResponse response = new HealthDetailsFreeIpaResponse();
NodeHealthDetails healthDetails1 = new NodeHealthDetails();
healthDetails1.setInstanceId("i-1");
healthDetails1.setStatus(status1);
NodeHealthDetails healthDetails2 = new NodeHealthDetails();
healthDetails2.setInstanceId("i-2");
healthDetails2.setStatus(status2);
response.setNodeHealthDetails(List.of(healthDetails1, healthDetails2));
return response;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsService method addUnreachableResponse.
private void addUnreachableResponse(InstanceMetaData instance, HealthDetailsFreeIpaResponse response, String issue) {
NodeHealthDetails nodeResponse = new NodeHealthDetails();
response.addNodeHealthDetailsFreeIpaResponses(nodeResponse);
nodeResponse.setName(instance.getDiscoveryFQDN());
nodeResponse.setStatus(InstanceStatus.UNREACHABLE);
nodeResponse.setInstanceId(instance.getInstanceId());
nodeResponse.addIssue(issue);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsService method getHealthDetails.
public HealthDetailsFreeIpaResponse getHealthDetails(String environmentCrn, String accountId) {
Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(environmentCrn, accountId);
List<InstanceMetaData> instances = stack.getAllInstanceMetaDataList();
HealthDetailsFreeIpaResponse response = new HealthDetailsFreeIpaResponse();
for (InstanceMetaData instance : instances) {
if (shouldRunHealthCheck(instance)) {
try {
NodeHealthDetails nodeHealthDetails = freeIpaInstanceHealthDetailsService.getInstanceHealthDetails(stack, instance);
response.addNodeHealthDetailsFreeIpaResponses(nodeHealthDetails);
} catch (Exception e) {
addUnreachableResponse(instance, response, e.getLocalizedMessage());
LOGGER.error(String.format("Unable to check the health of FreeIPA instance: %s", instance.getInstanceId()), e);
}
} else {
NodeHealthDetails nodeResponse = new NodeHealthDetails();
response.addNodeHealthDetailsFreeIpaResponses(nodeResponse);
nodeResponse.setName(instance.getDiscoveryFQDN());
nodeResponse.setStatus(instance.getInstanceStatus());
nodeResponse.setInstanceId(instance.getInstanceId());
nodeResponse.addIssue("Unable to check health as instance is " + instance.getInstanceStatus().name());
}
}
return updateResponse(stack, response);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse in project cloudbreak by hortonworks.
the class UpgradeCcmService method healthCheck.
public void healthCheck(Long stackId) {
Stack stack = stackService.getStackById(stackId);
HealthDetailsFreeIpaResponse healthDetails = healthService.getHealthDetails(stack.getEnvironmentCrn(), stack.getAccountId());
if (healthDetails.getNodeHealthDetails().stream().anyMatch(hd -> !hd.getStatus().isAvailable())) {
throw new CloudbreakServiceException("One or more FreeIPA instance is not available. Need to roll back CCM upgrade to previous version.");
}
// TODO: rollback if bad, but how?
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsServiceTest method testUnresponsiveSingleNodeThatThrowsRuntimeException.
@Test
public void testUnresponsiveSingleNodeThatThrowsRuntimeException() throws Exception {
Mockito.when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(anyString(), anyString())).thenReturn(getStack());
Mockito.when(freeIpaInstanceHealthDetailsService.getInstanceHealthDetails(any(), any())).thenThrow(new RuntimeException("Expected"));
HealthDetailsFreeIpaResponse response = underTest.getHealthDetails(ENVIRONMENT_ID, ACCOUNT_ID);
Assert.assertEquals(Status.UNREACHABLE, response.getStatus());
Assert.assertTrue(response.getNodeHealthDetails().size() == 1);
for (NodeHealthDetails nodeHealth : response.getNodeHealthDetails()) {
Assert.assertTrue(!nodeHealth.getIssues().isEmpty());
Assert.assertEquals(InstanceStatus.UNREACHABLE, nodeHealth.getStatus());
Assert.assertTrue(nodeHealth.getIssues().size() == 1);
Assert.assertTrue(nodeHealth.getIssues().get(0).equals("Expected"));
}
}
Aggregations