Search in sources :

Example 1 with UpgradeCcmFailureEvent

use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.

the class UpgradeCcmFlowIntegrationTest method verifyFinishingStatCalls.

private void verifyFinishingStatCalls(boolean success) {
    verify(upgradeCcmService, times(success ? 1 : 0)).finishedState(STACK_ID);
    verify(operationService, times(success ? 1 : 0)).completeOperation(any(), any(), any(), any());
    ArgumentCaptor<UpgradeCcmContext> contextCaptor = ArgumentCaptor.forClass(UpgradeCcmContext.class);
    ArgumentCaptor<UpgradeCcmFailureEvent> payloadCaptor = ArgumentCaptor.forClass(UpgradeCcmFailureEvent.class);
    verify(upgradeCcmService, times(success ? 0 : 1)).failedState(contextCaptor.capture(), payloadCaptor.capture());
    if (!success) {
        UpgradeCcmContext context = contextCaptor.getValue();
        UpgradeCcmFailureEvent payload = payloadCaptor.getValue();
        assertEquals(STACK_ID, context.getStack().getId());
        assertEquals(STACK_ID, payload.getResourceId());
    }
    verify(operationService, times(success ? 0 : 1)).failOperation(any(), any(), any());
}
Also used : UpgradeCcmContext(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.action.UpgradeCcmContext) UpgradeCcmFailureEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent)

Example 2 with UpgradeCcmFailureEvent

use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.

the class UpgradeCcmFlowChainIntegrationTest method verifyFinishingStatCalls.

private void verifyFinishingStatCalls(boolean ccmUpgradeSuccess, boolean userDataUpdateSuccess) throws Exception {
    verify(upgradeCcmService, times(ccmUpgradeSuccess ? 1 : 0)).finishedState(STACK_ID);
    verify(resourcesApi, times(userDataUpdateSuccess ? 1 : 0)).updateUserData(any(), any(), any(), eq(USER_DATA));
    ArgumentCaptor<UpgradeCcmContext> contextCaptor = ArgumentCaptor.forClass(UpgradeCcmContext.class);
    ArgumentCaptor<UpgradeCcmFailureEvent> payloadCaptor = ArgumentCaptor.forClass(UpgradeCcmFailureEvent.class);
    verify(upgradeCcmService, times(ccmUpgradeSuccess ? 0 : 1)).failedState(contextCaptor.capture(), payloadCaptor.capture());
    if (!ccmUpgradeSuccess) {
        UpgradeCcmContext context = contextCaptor.getValue();
        UpgradeCcmFailureEvent payload = payloadCaptor.getValue();
        assertEquals(STACK_ID, context.getStack().getId());
        assertEquals(STACK_ID, payload.getResourceId());
    }
    verify(operationService, times(ccmUpgradeSuccess && userDataUpdateSuccess ? 1 : 0)).completeOperation(any(), any(), any(), any());
    verify(operationService, times(ccmUpgradeSuccess && userDataUpdateSuccess ? 0 : 1)).failOperation(any(), any(), any());
}
Also used : UpgradeCcmContext(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.action.UpgradeCcmContext) UpgradeCcmFailureEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent)

Example 3 with UpgradeCcmFailureEvent

use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.

the class UpgradeCcmActions method failed.

@Bean(name = UPGRADE_CCM_FAILED_STATE_NAME)
public Action<?, ?> failed() {
    return new AbstractUpgradeCcmAction<>(UpgradeCcmFailureEvent.class) {

        @Override
        protected UpgradeCcmContext createFlowContext(FlowParameters flowParameters, StateContext<UpgradeCcmState, UpgradeCcmStateSelector> stateContext, UpgradeCcmFailureEvent payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            flow.setFlowFailed(payload.getException());
            return super.createFlowContext(flowParameters, stateContext, payload);
        }

        @Override
        protected void doExecute(UpgradeCcmContext context, UpgradeCcmFailureEvent payload, Map<Object, Object> variables) {
            LOGGER.info("FreeIPA CCM upgrade failed {}", payload);
            upgradeCcmService.failedState(context, payload);
            failOperation(context.getStack().getAccountId(), payload.getException().getMessage(), variables);
            sendEvent(context, UPGRADE_CCM_FAILURE_HANDLED_EVENT.event(), new StackEvent(context.getStack().getId()));
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StateContext(org.springframework.statemachine.StateContext) Map(java.util.Map) UpgradeCcmFailureEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Example 4 with UpgradeCcmFailureEvent

use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.

the class UpgradeCcmUpgradeHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmEvent> event) {
    UpgradeCcmEvent request = event.getData();
    if (request.getOldTunnel().useCcmV1()) {
        try {
            LOGGER.info("Running upgrade state for CCM...");
            upgradeCcmService.upgrade(request.getResourceId());
        } catch (CloudbreakOrchestratorException e) {
            LOGGER.debug("Failed applying CCM upgrade state");
            return new UpgradeCcmFailureEvent(UPGRADE_CCM_FAILED_EVENT.event(), request.getResourceId(), e);
        }
    } else {
        LOGGER.info("Running upgrade step is skipped for previous tunnel type '{}'", request.getOldTunnel());
    }
    return UPGRADE_CCM_UPGRADE_FINISHED_EVENT.createBasedOn(request);
}
Also used : UpgradeCcmEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmEvent) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) UpgradeCcmFailureEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent)

Aggregations

UpgradeCcmFailureEvent (com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent)4 UpgradeCcmContext (com.sequenceiq.freeipa.flow.stack.upgrade.ccm.action.UpgradeCcmContext)2 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 UpgradeCcmEvent (com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmEvent)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1