use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionFailureEvent in project cloudbreak by hortonworks.
the class DiagnosticsCollectionActions method failedAction.
@Bean(name = "DIAGNOSTICS_COLLECTION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionFailureEvent.class) {
@Override
protected void doExecute(CommonContext context, DiagnosticsCollectionFailureEvent payload, Map<Object, Object> variables) {
Long resourceId = payload.getResourceId();
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into DIAGNOSTICS_COLLECTION_FAILED_STATE. resourceCrn: '{}'", resourceCrn);
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_FAILED.name(), ResourceEvent.STACK_DIAGNOSTICS_COLLECTION_FAILED, List.of(payload.getException().getMessage()));
InMemoryStateStore.deleteStack(resourceId);
DiagnosticParameters parameters = payload.getParameters();
if (payload.getException() != null) {
parameters.setStatusReason(payload.getException().getMessage());
}
DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionStateSelectors.HANDLED_FAILED_DIAGNOSTICS_COLLECTION_EVENT.selector()).withParameters(payload.getParameters()).withHosts(payload.getHosts()).withHostGroups(payload.getHostGroups()).withExcludeHosts(payload.getExcludeHosts()).build();
diagnosticsOperationsService.vmDiagnosticsReport(resourceCrn, payload.getParameters(), UsageProto.CDPVMDiagnosticsFailureType.Value.valueOf(payload.getFailureType()), payload.getException());
sendEvent(context, event);
}
};
}
Aggregations