use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method cleanupFailureAction.
@Bean(name = "CLEANUP_FAILED_STATE")
public Action<?, ?> cleanupFailureAction() {
return new AbstractFreeIpaCleanupAction<>(CleanupFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(FreeIpaContext context, CleanupFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Cleanup failed with payload: " + payload);
String environmentCrn = payload.getEnvironmentCrn();
SuccessDetails successDetails = new SuccessDetails(environmentCrn);
successDetails.getAdditionalDetails().put(payload.getFailedPhase(), payload.getSuccess() == null ? List.of() : new ArrayList<>(payload.getSuccess()));
String message = "Cleanup failed during " + payload.getFailedPhase();
FailureDetails failureDetails = new FailureDetails(environmentCrn, message);
if (payload.getFailureDetails() != null) {
failureDetails.getAdditionalDetails().putAll(payload.getFailureDetails());
}
operationService.failOperation(payload.getAccountId(), payload.getOperationId(), message, List.of(successDetails), List.of(failureDetails));
sendEvent(context, FreeIpaCleanupEvent.CLEANUP_FAILURE_HANDLED_EVENT.event(), payload);
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<CleanupFailureEvent>> payloadConverters) {
payloadConverters.add(new RemoveDnsResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveHostsResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveRolesResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveUsersResponseToCleanupFailureEventConverter());
payloadConverters.add(new RevokeCertsResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveVaultEntriesResponseToCleanupFailureEventConverter());
}
};
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method failureAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_FAIL_STATE")
public Action<?, ?> failureAction() {
return new AbstractChangePrimaryGatewayAction<>(ChangePrimaryGatewayFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected ChangePrimaryGatewayContext createFlowContext(FlowParameters flowParameters, StateContext<ChangePrimaryGatewayState, ChangePrimaryGatewayFlowEvent> stateContext, ChangePrimaryGatewayFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected void doExecute(ChangePrimaryGatewayContext context, ChangePrimaryGatewayFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Change primary gateway 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 = "Change primary gateway 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(), DetailedStackStatus.REPAIR_FAILED, errorReason);
operationService.failOperation(stack.getAccountId(), getOperationId(variables), message, List.of(successDetails), List.of(failureDetails));
LOGGER.info("Enabling the status checker for stack ID {} after failing repairing", stack.getId());
enableStatusChecker(stack, "Failed to repair FreeIPA");
enableNodeStatusChecker(stack, "Failed to repair FreeIPA");
sendEvent(context, FAIL_HANDLED_EVENT.event(), payload);
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<ChangePrimaryGatewayFailureEvent>> payloadConverters) {
payloadConverters.add(new ClusterProxyUpdateRegistrationFailedToChangePrimaryGatewayFailureEventConverter());
payloadConverters.add(new HealthCheckFailedToChangePrimaryGatewayFailureEventConverter());
}
};
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class PasswordService method internalSetPasswords.
private void internalSetPasswords(String operationId, String accountId, String userCrn, String password, List<Stack> stacks) {
try {
String userId = getUserIdFromUserCrn(userCrn);
Optional<Instant> expirationInstant = calculateExpirationTime(userCrn, accountId);
List<SetPasswordRequest> requests = new ArrayList<>();
for (Stack stack : stacks) {
requests.add(triggerSetPassword(stack, stack.getEnvironmentCrn(), userId, userCrn, password, expirationInstant));
}
List<SuccessDetails> success = new ArrayList<>();
List<FailureDetails> failure = new ArrayList<>();
for (SetPasswordRequest request : requests) {
try {
waitSetPassword(request);
success.add(new SuccessDetails(request.getEnvironment()));
} catch (InterruptedException e) {
LOGGER.error("Interrupted while setting passwords for user {} in account {}", userCrn, accountId);
throw e;
} catch (Exception e) {
LOGGER.debug("Failed to set password for user {} in environment {}", userCrn, request.getEnvironment(), e);
failure.add(new FailureDetails(request.getEnvironment(), e.getLocalizedMessage()));
}
}
operationService.completeOperation(accountId, operationId, success, failure);
} catch (InterruptedException e) {
operationService.failOperation(accountId, operationId, e.getLocalizedMessage());
Thread.currentThread().interrupt();
} catch (RuntimeException e) {
operationService.failOperation(accountId, operationId, e.getLocalizedMessage());
throw e;
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class CoreImageProvider method getImages.
@Override
public List<ImageWrapper> getImages(ImageSettingsRequest imageSettings, String region, String platform) {
try {
ImagesV4Response imagesV4Response = imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), null, platform, null, null, false);
LOGGER.debug("Images received: {}", imagesV4Response);
return Optional.ofNullable(imagesV4Response.getFreeipaImages()).orElseGet(List::of).stream().map(this::convert).flatMap(Optional::stream).map(img -> new ImageWrapper(img, null, imageSettings.getCatalog())).collect(Collectors.toList());
} catch (WebApplicationException e) {
String errorMessage = messageExtractor.getErrorMessage(e);
LOGGER.warn("Fetching images failed with: {}", errorMessage, e);
return List.of();
} catch (Exception e) {
LOGGER.warn("Fetching images failed", e);
return List.of();
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class CleanupService method removeVaultEntries.
@Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION))
public Pair<Set<String>, Map<String, String>> removeVaultEntries(Long stackId, Set<String> hosts) throws FreeIpaClientException {
Set<String> vaultCleanupSuccess = new HashSet<>();
Map<String, String> vaultCleanupFailed = new HashMap<>();
Stack stack = stackService.getStackById(stackId);
FreeIpaClient freeIpaClient = getFreeIpaClient(stackId);
for (String host : hosts) {
try {
HostRequest hostRequest = new HostRequest();
hostRequest.setEnvironmentCrn(stack.getEnvironmentCrn());
hostRequest.setServerHostName(host);
keytabCleanupService.removeHostRelatedKerberosConfiguration(hostRequest, stack.getAccountId(), freeIpaClient);
vaultCleanupSuccess.add(host);
} catch (DeleteException | FreeIpaClientException e) {
LOGGER.info("Vault secret cleanup failed for host: {}", host, e);
vaultCleanupFailed.put(host, e.getMessage());
}
}
return Pair.of(vaultCleanupSuccess, vaultCleanupFailed);
}
Aggregations