use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleFailureAction.
@Bean(name = "DOWNSCALE_FAIL_STATE")
public Action<?, ?> downscaleFailureAction() {
return new AbstractDownscaleAction<>(DownscaleFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<DownscaleState, DownscaleFlowEvent> stateContext, DownscaleFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected void doExecute(StackContext context, DownscaleFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Downscale failed with payload: " + payload);
Stack stack = context.getStack();
String environmentCrn = stack.getEnvironmentCrn();
SuccessDetails successDetails = new SuccessDetails(environmentCrn);
successDetails.getAdditionalDetails().put(payload.getFailedPhase(), payload.getSuccess() == null ? List.of() : new ArrayList<>(payload.getSuccess()));
String message = "Downscale failed during " + payload.getFailedPhase();
FailureDetails failureDetails = new FailureDetails(environmentCrn, message);
if (payload.getFailureDetails() != null) {
failureDetails.getAdditionalDetails().putAll(payload.getFailureDetails());
}
String errorReason = getErrorReason(payload.getException());
stackUpdater.updateStackStatus(context.getStack().getId(), getFailedStatus(variables), errorReason);
operationService.failOperation(stack.getAccountId(), getOperationId(variables), message, List.of(successDetails), List.of(failureDetails));
enableStatusChecker(stack, "Failed downscaling FreeIPA");
enableNodeStatusChecker(stack, "Failed downscaling FreeIPA");
sendEvent(context, FAIL_HANDLED_EVENT.event(), payload);
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<DownscaleFailureEvent>> payloadConverters) {
payloadConverters.add(new ClusterProxyUpdateRegistrationFailedToDownscaleFailureEventConverter());
payloadConverters.add(new DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter());
payloadConverters.add(new DownscaleStackResultToDownscaleFailureEventConverter());
payloadConverters.add(new RemoveServersResponseToDownscaleFailureEventConverter());
payloadConverters.add(new RemoveDnsResponseToDownscaleFailureEventConverter());
payloadConverters.add(new RemoveHostsResponseToDownscaleFailureEventConverter());
payloadConverters.add(new RevokeCertsResponseToDownscaleFailureEventConverter());
}
};
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaDeletionRetrievalTask method checkStatus.
@Override
public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) {
String environmentCrn = freeIpaPollerObject.getEnvironmentCrn();
try {
LOGGER.info("Checking the state of FreeIpa termination progress for environment: '{}'", environmentCrn);
Optional<DescribeFreeIpaResponse> freeIpaResponse = freeIpaService.describe(environmentCrn);
if (freeIpaResponse.isPresent()) {
if (freeIpaResponse.get().getStatus() == Status.DELETE_FAILED) {
throw new FreeIpaOperationFailedException("FreeIpa deletion operation failed: " + freeIpaResponse.get().getStatusReason());
}
if (!freeIpaResponse.get().getStatus().isSuccessfullyDeleted()) {
return false;
}
} else {
LOGGER.info("FreeIpa was not found.");
return true;
}
} catch (Exception e) {
throw new FreeIpaOperationFailedException("FreeIpa deletion operation failed. " + e.getMessage(), e);
}
return true;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsServiceTest method getUnhealthyDetails2.
private NodeHealthDetails getUnhealthyDetails2() {
NodeHealthDetails nodeHealthDetails = new NodeHealthDetails();
nodeHealthDetails.setInstanceId(INSTANCE_ID2);
nodeHealthDetails.setName(HOST2);
nodeHealthDetails.setStatus(InstanceStatus.UNHEALTHY);
nodeHealthDetails.setIssues(List.of("failed"));
return nodeHealthDetails;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsServiceTest method getUnhealthyDetails1.
private NodeHealthDetails getUnhealthyDetails1() {
NodeHealthDetails nodeHealthDetails = new NodeHealthDetails();
nodeHealthDetails.setInstanceId(INSTANCE_ID1);
nodeHealthDetails.setName(HOST1);
nodeHealthDetails.setStatus(InstanceStatus.UNHEALTHY);
nodeHealthDetails.setIssues(List.of("failed"));
return nodeHealthDetails;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaScalingServiceTest method testUpscaleIfValidationFailsThenErrorThrown.
@Test
public void testUpscaleIfValidationFailsThenErrorThrown() {
Stack stack = mock(Stack.class);
Set<InstanceMetaData> allInstances = createValidImSet();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
UpscaleRequest request = createUpscaleRequest();
doThrow(new BadRequestException("validation failed")).when(validationService).validateStackForUpscale(allInstances, stack, new ScalingPath(AvailabilityType.TWO_NODE_BASED, AvailabilityType.HA));
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.upscale(ACCOUNT_ID, request));
assertEquals(exception.getMessage(), "validation failed");
}
Aggregations