use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent in project cloudbreak by hortonworks.
the class ValidateInstancesHealthHandlerTest method testExceptionDuringHealthCheck.
@Test
public void testExceptionDuringHealthCheck() throws FreeIpaClientException {
Stack stack = new Stack();
stack.setId(1L);
when(stackService.getStackById(1L)).thenReturn(stack);
List<String> instanceIds = List.of("im1", "im2");
InstanceMetaData im1 = new InstanceMetaData();
im1.setInstanceId("im1");
im1.setDiscoveryFQDN("im1Fqdn");
InstanceMetaData im2 = new InstanceMetaData();
im2.setInstanceId("im2");
im2.setDiscoveryFQDN("im2Fqdn");
when(instanceMetaDataService.getNotTerminatedByInstanceIds(1L, instanceIds)).thenReturn(Set.of(im1, im2));
when(healthService.getInstanceHealthDetails(stack, im1)).thenReturn(createHealthyNodeDetail(im1));
when(healthService.getInstanceHealthDetails(stack, im2)).thenThrow(new FreeIpaClientException("nono"));
ValidateInstancesHealthEvent validateInstancesHealthEvent = new ValidateInstancesHealthEvent(1L, instanceIds);
UpscaleFailureEvent result = (UpscaleFailureEvent) underTest.doAccept(new HandlerEvent<>(new Event<>(validateInstancesHealthEvent)));
assertEquals(1L, result.getResourceId());
assertEquals(PHASE, result.getFailedPhase());
assertTrue(result.getSuccess().contains("im1"));
assertEquals(1, result.getFailureDetails().size());
assertEquals("nono", result.getFailureDetails().get("im2"));
assertEquals("Unhealthy instances found: [im2]", result.getException().getMessage());
}
use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method tlsSetupAction.
@Bean(name = "UPSCALE_TLS_SETUP_STATE")
public Action<?, ?> tlsSetupAction() {
return new AbstractUpscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Setting up TLS");
StackEvent event;
try {
if (!stack.getTunnel().useCcm()) {
Set<InstanceMetaData> newInstancesMetaData = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getAllInstanceMetaData().stream()).filter(this::isNewInstancesWithoutTlsCert).collect(Collectors.toSet());
for (InstanceMetaData gwInstance : newInstancesMetaData) {
tlsSetupService.setupTls(stack.getId(), gwInstance);
}
}
event = new StackEvent(UpscaleFlowEvent.UPSCALE_TLS_SETUP_FINISHED_EVENT.event(), stack.getId());
} catch (Exception e) {
LOGGER.error("Failed to setup TLS", e);
event = new UpscaleFailureEvent(stack.getId(), "Setting ups TLS", Set.of(), Map.of(), e);
}
sendEvent(context, event.selector(), event);
}
private boolean isNewInstancesWithoutTlsCert(InstanceMetaData instanceMetaData) {
return instanceMetaData.getInstanceStatus().equals(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus.CREATED) && Objects.isNull(instanceMetaData.getServerCert());
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent in project cloudbreak by hortonworks.
the class BootstrapMachinesFailedToUpscaleFailureEventConverter method convert.
@Override
public UpscaleFailureEvent convert(Object payload) {
BootstrapMachinesFailed result = (BootstrapMachinesFailed) payload;
UpscaleFailureEvent event = new UpscaleFailureEvent(result.getResourceId(), "Bootstrapping machines", Set.of(), Map.of(), new Exception("Payload failed: " + payload));
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent in project cloudbreak by hortonworks.
the class PostInstallFreeIpaFailedToUpscaleFailureEventConverter method convert.
@Override
public UpscaleFailureEvent convert(Object payload) {
PostInstallFreeIpaFailed result = (PostInstallFreeIpaFailed) payload;
UpscaleFailureEvent event = new UpscaleFailureEvent(result.getResourceId(), "Post installing FreeIPA", Set.of(), Map.of(), new Exception("Payload failed: " + payload));
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent in project cloudbreak by hortonworks.
the class ValidateInstancesHealthHandlerTest method testUnHealthy.
@Test
public void testUnHealthy() throws FreeIpaClientException {
Stack stack = new Stack();
stack.setId(1L);
when(stackService.getStackById(1L)).thenReturn(stack);
List<String> instanceIds = List.of("im1", "im2");
InstanceMetaData im1 = new InstanceMetaData();
im1.setInstanceId("im1");
im1.setDiscoveryFQDN("im1Fqdn");
InstanceMetaData im2 = new InstanceMetaData();
im2.setInstanceId("im2");
im2.setDiscoveryFQDN("im2Fqdn");
when(instanceMetaDataService.getNotTerminatedByInstanceIds(1L, instanceIds)).thenReturn(Set.of(im1, im2));
when(healthService.getInstanceHealthDetails(stack, im1)).thenReturn(createHealthyNodeDetail(im1));
NodeHealthDetails unhealthy = createHealthyNodeDetail(im2);
unhealthy.setStatus(InstanceStatus.UNHEALTHY);
unhealthy.setIssues(List.of("bad"));
when(healthService.getInstanceHealthDetails(stack, im2)).thenReturn(unhealthy);
ValidateInstancesHealthEvent validateInstancesHealthEvent = new ValidateInstancesHealthEvent(1L, instanceIds);
UpscaleFailureEvent result = (UpscaleFailureEvent) underTest.doAccept(new HandlerEvent<>(new Event<>(validateInstancesHealthEvent)));
assertEquals(1L, result.getResourceId());
assertEquals(PHASE, result.getFailedPhase());
assertTrue(result.getSuccess().contains("im1"));
assertEquals(1, result.getFailureDetails().size());
assertEquals("bad", result.getFailureDetails().get("im2"));
assertEquals("Unhealthy instances found: [im2]", result.getException().getMessage());
}
Aggregations