use of com.sequenceiq.freeipa.service.operation.OperationService 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.service.operation.OperationService 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.service.operation.OperationService in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method cleanupFinishedAction.
@Bean(name = "CLEANUP_FINISHED_STATE")
public Action<?, ?> cleanupFinishedAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveRolesResponse.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(FreeIpaContext context, RemoveRolesResponse payload, Map<Object, Object> variables) {
CleanupEvent cleanupEvent = new CleanupEvent(FreeIpaCleanupEvent.CLEANUP_FINISHED_EVENT.event(), payload.getResourceId(), payload.getUsers(), payload.getHosts(), payload.getRoles(), payload.getIps(), payload.getStatesToSkip(), payload.getAccountId(), payload.getOperationId(), payload.getClusterName(), payload.getEnvironmentCrn());
SuccessDetails successDetails = new SuccessDetails(payload.getEnvironmentCrn());
successDetails.getAdditionalDetails().put("Hosts", payload.getHosts() == null ? List.of() : new ArrayList<>(payload.getHosts()));
successDetails.getAdditionalDetails().put("Users", payload.getUsers() == null ? List.of() : new ArrayList<>(payload.getUsers()));
successDetails.getAdditionalDetails().put("Roles", payload.getRoles() == null ? List.of() : new ArrayList<>(payload.getRoles()));
successDetails.getAdditionalDetails().put("IPs", payload.getIps() == null ? List.of() : new ArrayList<>(payload.getIps()));
operationService.completeOperation(payload.getAccountId(), payload.getOperationId(), List.of(successDetails), Collections.emptyList());
LOGGER.info("Cleanup successfully finished with: " + successDetails);
sendEvent(context, cleanupEvent);
}
};
}
use of com.sequenceiq.freeipa.service.operation.OperationService in project cloudbreak by hortonworks.
the class FullBackupActions method backupFailedAction.
@Bean(name = "BACKUP_FAILED_STATE")
public Action<?, ?> backupFailedAction() {
return new AbstractBackupAction<>(StackFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(BackupContext context, StackFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Full backup failed", payload.getException());
failFlow(context, payload);
if (isOperationIdSet(variables)) {
LOGGER.debug("Fail operation with id: [{}]", getOperationId(variables));
operationService.failOperation(context.getStack().getAccountId(), getOperationId(variables), payload.getException().getMessage());
}
sendEvent(context, new StackEvent(FULL_BACKUP_FAILURE_HANDLED_EVENT.event(), payload.getResourceId()));
}
private void failFlow(BackupContext context, StackFailureEvent payload) {
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
}
};
}
use of com.sequenceiq.freeipa.service.operation.OperationService in project cloudbreak by hortonworks.
the class FullBackupActions method backupFinishedAction.
@Bean(name = "BACKUP_FINISHED_STATE")
public Action<?, ?> backupFinishedAction() {
return new AbstractBackupAction<>(StackEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(BackupContext context, StackEvent payload, Map<Object, Object> variables) {
LOGGER.info("Full backup flow finished");
if (isOperationIdSet(variables) && (!isChainedAction(variables) || isFinalChain(variables))) {
LOGGER.debug("Complete operation with id: [{}]", getOperationId(variables));
Stack stack = context.getStack();
SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
operationService.completeOperation(stack.getAccountId(), getOperationId(variables), Set.of(successDetails), Set.of());
}
sendEvent(context, new StackEvent(FULL_BACKUP_FINISHED_EVENT.event(), payload.getResourceId()));
}
};
}
Aggregations