use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method cleanUp.
private void cleanUp(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
try {
CleanupRequest cleanupRequest = new CleanupRequest();
cleanupRequest.setEnvironmentCrn(environmentCrn);
cleanupRequest.setClusterName("testuser");
cleanupRequest.setUsers(Set.of("kerberosbind-testuser", "ldapbind-testuser"));
OperationStatus operationStatus = ipaClient.getFreeIpaV1Endpoint().cleanup(cleanupRequest);
waitToCompleted(testContext, operationStatus.getOperationId(), "cleanupOperation");
} catch (Exception e) {
logger.error("CLEANUP test failed during upgrade", e);
// throw new TestFailException("CLEANUP test failed during upgrade with: " + e.getMessage(), e);
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method addListDeleteDnsZonesBySubnet.
private void addListDeleteDnsZonesBySubnet(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
try {
AddDnsZoneForSubnetsRequest request = new AddDnsZoneForSubnetsRequest();
request.setSubnets(List.of("10.0.1.0/24", "192.168.1.0/24"));
request.setEnvironmentCrn(environmentCrn);
ipaClient.getDnsV1Endpoint().addDnsZoneForSubnets(request);
/* Until CB-15454 is fixed
Set<String> dnsZones = ipaClient.getDnsV1Endpoint().listDnsZones(environmentCrn);
Assertions.assertTrue(dnsZones.stream().anyMatch(dnsZone -> dnsZone.startsWith("1.0.10")));
Assertions.assertTrue(dnsZones.stream().anyMatch(dnsZone -> dnsZone.startsWith("1.168.192")));*/
ipaClient.getDnsV1Endpoint().deleteDnsZoneBySubnet(environmentCrn, "192.168.1.0/24");
ipaClient.getDnsV1Endpoint().deleteDnsZoneBySubnet(environmentCrn, "10.0.1.0/24");
/* dnsZones = ipaClient.getDnsV1Endpoint().listDnsZones(environmentCrn);
Assertions.assertFalse(dnsZones.stream().anyMatch(dnsZone -> dnsZone.startsWith("1.0.10")));
Assertions.assertFalse(dnsZones.stream().anyMatch(dnsZone -> dnsZone.startsWith("1.168.192")));*/
} catch (Exception e) {
logger.error("DNS ZONE test failed during upgrade", e);
throw new TestFailException("DNS ZONE test failed during upgrade with: " + e.getMessage(), e);
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class StartBindUserCreationServiceTest method testOperationFailed.
@Test
public void testOperationFailed() {
OperationStatus operationStatus = new OperationStatus(OPERATION_ID, OperationType.BIND_USER_CREATE, OperationState.FAILED, List.of(), List.of(), "errMsg", 1L, 2L);
when(freeIpaV1Endpoint.createBindUser(any(BindUserCreateRequest.class), anyString())).thenReturn(operationStatus);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
StackEvent result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.startBindUserCreation(stackView));
assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
assertEquals(STACK_ID, result.getResourceId());
assertEquals("Failed to start bind user creation operation: errMsg", ((StackFailureEvent) result).getException().getMessage());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method upscaleFailureAction.
@Bean(name = "UPSCALE_FAIL_STATE")
public Action<?, ?> upscaleFailureAction() {
return new AbstractUpscaleAction<>(UpscaleFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<UpscaleState, UpscaleFlowEvent> stateContext, UpscaleFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected void doExecute(StackContext context, UpscaleFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Upscale 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 = "Upscale 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 upscaling FreeIPA");
enableNodeStatusChecker(stack, "Failed upscaling FreeIPA");
sendEvent(context, FAIL_HANDLED_EVENT.event(), payload);
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<UpscaleFailureEvent>> payloadConverters) {
payloadConverters.add(new UpscaleStackResultToUpscaleFailureEventConverter());
payloadConverters.add(new CollectMetadataResultToUpscaleFailureEventConverter());
payloadConverters.add(new BootstrapMachinesFailedToUpscaleFailureEventConverter());
payloadConverters.add(new HostMetadataSetupFailedToUpscaleFailureEventConverter());
payloadConverters.add(new InstallFreeIpaServicesFailedToUpscaleFailureEventConverter());
payloadConverters.add(new ClusterProxyUpdateRegistrationFailedToUpscaleFailureEventConverter());
payloadConverters.add(new PostInstallFreeIpaFailedToUpscaleFailureEventConverter());
}
};
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method validateInstancesAction.
@Bean(name = "UPSCALE_VALIDATE_INSTANCES_STATE")
public Action<?, ?> validateInstancesAction() {
return new AbstractUpscaleAction<>(UpscaleStackResult.class) {
@Override
protected void doExecute(StackContext context, UpscaleStackResult payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Validating new instances");
try {
finishAddInstances(context, payload);
sendEvent(context, UPSCALE_VALIDATE_INSTANCES_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
} catch (Exception e) {
LOGGER.error("Failed to validate the instances", e);
sendEvent(context, UPSCALE_VALIDATE_INSTANCES_FAILED_EVENT.selector(), new UpscaleFailureEvent(stack.getId(), "Validating new instances", Set.of(), Map.of(), e));
}
}
private void finishAddInstances(StackContext context, UpscaleStackResult payload) {
LOGGER.debug("Upscale stack result: {}", payload);
List<CloudResourceStatus> results = payload.getResults();
validateResourceResults(context, payload.getErrorDetails(), results);
Set<Resource> resourceSet = transformResults(results, context.getStack());
if (resourceSet.isEmpty()) {
metadataSetupService.cleanupRequestedInstances(context.getStack());
throw new OperationException("Failed to upscale the cluster since all create request failed. Resource set is empty");
}
LOGGER.debug("Adding new instances to the stack is DONE");
}
private void validateResourceResults(StackContext context, Exception exception, List<CloudResourceStatus> results) {
if (exception != null) {
LOGGER.info(format("Failed to upscale stack: %s", context.getCloudContext()), exception);
throw new OperationException(exception);
}
List<CloudResourceStatus> missingResources = results.stream().filter(result -> CommonResourceType.TEMPLATE == result.getCloudResource().getType().getCommonResourceType()).filter(status -> status.isFailed() || status.isDeleted()).collect(Collectors.toList());
if (!missingResources.isEmpty()) {
StringBuilder message = new StringBuilder("Failed to upscale the stack for ").append(context.getCloudContext()).append(" due to: ");
missingResources.forEach(res -> message.append("[privateId: ").append(res.getPrivateId()).append(", statusReason: ").append(res.getStatusReason()).append("] "));
LOGGER.warn(message.toString());
throw new OperationException(message.toString());
}
}
private Set<Resource> transformResults(Iterable<CloudResourceStatus> cloudResourceStatuses, Stack stack) {
Set<Resource> retSet = new HashSet<>();
for (CloudResourceStatus cloudResourceStatus : cloudResourceStatuses) {
if (!cloudResourceStatus.isFailed()) {
CloudResource cloudResource = cloudResourceStatus.getCloudResource();
Resource resource = new Resource(cloudResource.getType(), cloudResource.getName(), cloudResource.getReference(), cloudResource.getStatus(), stack, null, cloudResource.getAvailabilityZone());
retSet.add(resource);
}
}
return retSet;
}
};
}
Aggregations