use of com.sequenceiq.cloudbreak.common.type.HealthCheck in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusService method getCertCheck.
private static Optional<HealthCheck> getCertCheck(ApiHost apiHost) {
Optional<ApiHealthCheck> healthCheck = emptyIfNull(apiHost.getHealthChecks()).stream().filter(health -> HOST_AGENT_CERTIFICATE_EXPIRY.equals(health.getName())).findFirst();
if (healthCheck.isPresent()) {
HealthCheckResult result = ApiHealthSummary.BAD.equals(healthCheck.get().getSummary()) || ApiHealthSummary.CONCERNING.equals(healthCheck.get().getSummary()) ? HealthCheckResult.UNHEALTHY : HealthCheckResult.HEALTHY;
Optional<String> reason = Optional.ofNullable(healthCheck.get().getSummary()).map(apiSum -> "Cert health on CM: " + apiSum.getValue());
return Optional.of(new HealthCheck(HealthCheckType.CERT, result, reason));
}
return Optional.empty();
}
use of com.sequenceiq.cloudbreak.common.type.HealthCheck in project cloudbreak by hortonworks.
the class VmStatusCheckerConclusionStep method checkCMForInstanceStatuses.
private Conclusion checkCMForInstanceStatuses(ClusterApi connector, Set<InstanceMetaData> runningInstances, Long clusterId) {
ExtendedHostStatuses extendedHostStatuses = connector.clusterStatusService().getExtendedHostStatuses(runtimeVersionService.getRuntimeVersion(clusterId));
Map<HostName, Set<HealthCheck>> hostStatuses = extendedHostStatuses.getHostsHealth();
Map<String, String> unhealthyHosts = hostStatuses.keySet().stream().filter(hostName -> !extendedHostStatuses.isHostHealthy(hostName)).collect(Collectors.toMap(StringType::value, extendedHostStatuses::statusReasonForHost));
Set<String> noReportHosts = runningInstances.stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).filter(discoveryFQDN -> !hostStatuses.containsKey(hostName(discoveryFQDN))).collect(toSet());
if (!unhealthyHosts.isEmpty() || !noReportHosts.isEmpty()) {
String conclusion = String.format("Unhealthy and/or unknown VMs found based on CM status. Unhealthy VMs: %s, unknown VMs: %s. " + "Please check the instances on your cloud provider for further details.", unhealthyHosts, noReportHosts);
String details = String.format("Unhealthy and/or unknown VMs found based on CM status. Unhealthy VMs: %s, unknown VMs: %s", unhealthyHosts, noReportHosts);
LOGGER.warn(details);
return failed(conclusion, details);
} else {
return succeeded();
}
}
use of com.sequenceiq.cloudbreak.common.type.HealthCheck in project cloudbreak by hortonworks.
the class StackStatusCheckerJobTest method internalTestInstanceSyncStopStart.
private void internalTestInstanceSyncStopStart(String instanceHgName, InstanceStatus instanceStatus, DetailedStackStatus expected) throws JobExecutionException {
setupForCM();
Set<HealthCheck> healthChecks = Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, HealthCheckResult.UNHEALTHY, Optional.empty()), new HealthCheck(HealthCheckType.CERT, HealthCheckResult.UNHEALTHY, Optional.empty()));
ExtendedHostStatuses extendedHostStatuses = new ExtendedHostStatuses(Map.of(HostName.hostName("host1"), healthChecks));
when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(extendedHostStatuses);
when(instanceMetaData.getInstanceStatus()).thenReturn(instanceStatus);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.datahub()).thenReturn(regionAwareInternalCrnGenerator);
when(instanceMetaData.getDiscoveryFQDN()).thenReturn("host1");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName(instanceHgName);
when(instanceMetaData.getInstanceGroup()).thenReturn(instanceGroup);
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(stackUtil.stopStartScalingEntitlementEnabled(any())).thenReturn(true);
Set<String> computeGroups = new HashSet<>();
computeGroups.add("compute");
when(cmTemplateProcessor.getComputeHostGroups(any())).thenReturn(computeGroups);
underTest.executeTracedJob(jobExecutionContext);
verify(clusterOperationService, times(1)).reportHealthChange(any(), any(), anySet());
verify(stackInstanceStatusChecker).queryInstanceStatuses(eq(stack), any());
verify(clusterService, times(1)).updateClusterCertExpirationState(stack.getCluster(), true);
verify(clusterService, times(1)).updateClusterStatusByStackId(stack.getId(), expected);
}
use of com.sequenceiq.cloudbreak.common.type.HealthCheck in project cloudbreak by hortonworks.
the class StackStatusCheckerJobTest method testInstanceSyncCMRunningNodeStopped.
@Test
public void testInstanceSyncCMRunningNodeStopped() throws JobExecutionException {
setupForCM();
Set<HealthCheck> healthChecks = Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, HealthCheckResult.UNHEALTHY, Optional.empty()), new HealthCheck(HealthCheckType.CERT, HealthCheckResult.UNHEALTHY, Optional.empty()));
ExtendedHostStatuses extendedHostStatuses = new ExtendedHostStatuses(Map.of(HostName.hostName("host1"), healthChecks));
when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(extendedHostStatuses);
when(instanceMetaData.getInstanceStatus()).thenReturn(InstanceStatus.STOPPED);
when(instanceMetaData.getDiscoveryFQDN()).thenReturn("host1");
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.datahub()).thenReturn(regionAwareInternalCrnGenerator);
underTest.executeTracedJob(jobExecutionContext);
verify(clusterOperationService, times(1)).reportHealthChange(any(), any(), anySet());
verify(stackInstanceStatusChecker).queryInstanceStatuses(eq(stack), any());
verify(clusterService, times(1)).updateClusterCertExpirationState(stack.getCluster(), true);
verify(clusterService, times(1)).updateClusterStatusByStackId(stack.getId(), DetailedStackStatus.NODE_FAILURE);
}
use of com.sequenceiq.cloudbreak.common.type.HealthCheck in project cloudbreak by hortonworks.
the class ClusterServiceTest method setupClusterApi.
private void setupClusterApi(Stack stack, HealthCheckResult healthCheckResult, String statusReason) {
ClusterApi connector = mock(ClusterApi.class);
ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
when(clusterStatusService.isClusterManagerRunning()).thenReturn(true);
when(connector.clusterStatusService()).thenReturn(clusterStatusService);
Map<HostName, Set<HealthCheck>> clusterManagerStateMap = new HashMap<>();
if (healthCheckResult != null) {
clusterManagerStateMap.put(HostName.hostName(FQDN1), Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, healthCheckResult, Optional.ofNullable(statusReason))));
}
ExtendedHostStatuses extendedHostStatuses = new ExtendedHostStatuses(clusterManagerStateMap);
when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(extendedHostStatuses);
when(clusterApiConnectors.getConnector(stack)).thenReturn(connector);
}
Aggregations