use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedCmSyncRequest in project cloudbreak by hortonworks.
the class ClusterUpgradeActions method clusterUpgradeFailedAction.
@Bean(name = "CLUSTER_UPGRADE_FAILED_STATE")
public Action<?, ?> clusterUpgradeFailedAction() {
return new AbstractClusterUpgradeAction<>(ClusterUpgradeFailedEvent.class) {
@Value("${cb.upgrade.failure.sync.sdx.enabled}")
private boolean syncAfterFailureEnabled;
@Override
protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, ClusterUpgradeFailedEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
Stack stack = stackService.getById(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
flow.setFlowFailed(payload.getException());
return ClusterUpgradeContext.from(flowParameters, payload);
}
@Override
protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeFailedEvent payload, Map<Object, Object> variables) {
clusterUpgradeService.handleUpgradeClusterFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
if (syncAfterFailureEnabled) {
LOGGER.debug("Starting syncing parcel and CM version from CM to DB.");
try {
Set<Image> candidateImages = new HashSet<>();
Optional.ofNullable(getCurrentImage(variables)).ifPresent(si -> candidateImages.add(si.getImage()));
Optional.ofNullable(getTargetImage(variables)).ifPresent(si -> candidateImages.add(si.getImage()));
ClusterUpgradeFailedCmSyncRequest cmSyncRequest = new ClusterUpgradeFailedCmSyncRequest(payload.getResourceId(), payload.getException(), payload.getDetailedStatus(), candidateImages);
sendEvent(context, cmSyncRequest);
} catch (Exception e) {
LOGGER.warn("Error starting syncing CM version to DB, syncing skipped: ", e);
sendEvent(context, new ClusterUpgradeFailHandledRequest(payload.getResourceId(), payload.getException(), payload.getDetailedStatus()));
}
} else {
LOGGER.debug("Syncing from CM to DB is not enabled.");
sendEvent(context, new ClusterUpgradeFailHandledRequest(payload.getResourceId(), payload.getException(), payload.getDetailedStatus()));
}
}
@Override
protected Object getFailurePayload(ClusterUpgradeFailedEvent payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
return null;
}
};
}
use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedCmSyncRequest in project cloudbreak by hortonworks.
the class ClusterUpgradeFailedCmSyncHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeFailedCmSyncRequest> event) {
ClusterUpgradeFailedCmSyncRequest request = event.getData();
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
cmSyncerService.syncFromCmToDb(stack, request.getCandidateImages());
} catch (Exception e) {
LOGGER.warn("Error during syncing CM version to DB, syncing skipped.", e);
}
return new ClusterUpgradeFailHandledRequest(request.getResourceId(), request.getException(), request.getDetailedStatus());
}
Aggregations