Search in sources :

Example 1 with UpgradeCcmFailedEvent

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.

the class UpgradeCcmActionsTest method failureAction.

@Test
void failureAction() {
    IllegalStateException failureException = new IllegalStateException(MESSAGE);
    actionPayload = new UpgradeCcmFailedEvent(SDX_ID, USER_ID, failureException);
    setupContextWithPayload();
    testUpgradeActionHappyPath(underTest::failedAction);
    UpgradeCcmFailedEvent payload = (UpgradeCcmFailedEvent) payloadArgumentCaptor.getValue();
    assertThat(selectorArgumentCaptor.getValue()).isEqualTo(UPGRADE_CCM_FAILED_HANDLED_EVENT.event());
    assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
    assertThat(payload.getUserId()).isEqualTo(USER_ID);
    verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.DATALAKE_UPGRADE_CCM_FAILED, MESSAGE, SDX_ID);
    verify(metricService).incrementMetricCounter(eq(MetricType.UPGRADE_CCM_FAILED), (SdxCluster) any());
}
Also used : UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) Test(org.junit.jupiter.api.Test)

Example 2 with UpgradeCcmFailedEvent

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.

the class UpgradeCcmStackHandlerTest method acceptWithExceptions.

@ParameterizedTest
@ValueSource(classes = { UserBreakException.class, PollerStoppedException.class, PollerException.class })
void acceptWithExceptions(Class<? extends Throwable> errorClass) throws Exception {
    UpgradeCcmStackRequest request = new UpgradeCcmStackRequest(1L, "user");
    Event.Headers headers = new Event.Headers();
    Event<UpgradeCcmStackRequest> event = new Event<>(headers, request);
    when(sdxService.getById(any())).thenReturn(getSdxCluster());
    doThrow(errorClass).when(ccmUpgradeService).initAndWaitForStackUpgrade(any(SdxCluster.class), any(PollingConfig.class));
    Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
    UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(1L, "user", new Exception("error"));
    assertThat(selectable).usingRecursiveComparison().isEqualTo(failedEvent);
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Event(reactor.bus.Event) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with UpgradeCcmFailedEvent

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.

the class UpgradeCcmActions method failedAction.

@Bean(name = "UPGRADE_CCM_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new AbstractUpgradeCcmSdxAction<>(UpgradeCcmFailedEvent.class) {

        @Override
        protected void doExecute(SdxContext context, UpgradeCcmFailedEvent payload, Map<Object, Object> variables) {
            Exception exception = payload.getException();
            DatalakeStatusEnum failedStatus = DatalakeStatusEnum.DATALAKE_UPGRADE_CCM_FAILED;
            LOGGER.info("Update SDX status to {} for resource: {}", failedStatus, payload.getResourceId(), exception);
            String statusReason = "Cluster Connectivity Manager upgrade failed";
            if (exception.getMessage() != null) {
                statusReason = exception.getMessage();
            }
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(failedStatus, statusReason, payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.UPGRADE_CCM_FAILED, sdxCluster);
            sendEvent(context, UPGRADE_CCM_FAILED_HANDLED_EVENT.event(), payload);
        }
    };
}
Also used : DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 4 with UpgradeCcmFailedEvent

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.

the class UpgradeCcmStackHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmStackRequest> event) {
    UpgradeCcmStackRequest request = event.getData();
    SdxCluster sdxCluster = sdxService.getById(request.getResourceId());
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Initiating CCM upgrade and start polling for SDX: {}", sdxCluster.getName());
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        ccmUpgradeService.initAndWaitForStackUpgrade(sdxCluster, pollingConfig);
        response = new UpgradeCcmSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Upgrade CCM poller exited before timeout. Cause: ", userBreakException);
        response = new UpgradeCcmFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Upgrade CCM poller stopped for stack: {}", sdxId);
        response = new UpgradeCcmFailedEvent(sdxId, userId, new PollerStoppedException("Upgrade CCM timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Upgrade CCM polling failed for stack: {}", sdxId);
        response = new UpgradeCcmFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) PollerException(com.dyngr.exception.PollerException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

UpgradeCcmFailedEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)4 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 PollerException (com.dyngr.exception.PollerException)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)2 UserBreakException (com.dyngr.exception.UserBreakException)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)2 UpgradeCcmStackRequest (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest)2 UpgradeCcmSuccessEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent)2 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)2 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 Bean (org.springframework.context.annotation.Bean)1 Event (reactor.bus.Event)1