Search in sources :

Example 66 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class MaintenanceModeValidationService method validateImageCatalog.

public List<Warning> validateImageCatalog(Stack stack) {
    List<Warning> warnings = new ArrayList<>();
    try {
        Image image = componentConfigProviderService.getImage(stack.getId());
        StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId());
        if (!image.getPackageVersions().isEmpty()) {
            CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage);
            if (checkResult.getStatus().equals(EventStatus.FAILED)) {
                warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage()));
            }
        }
    } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
        throw new CloudbreakServiceException("Image info could not be validated!", e);
    }
    return warnings;
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) ArrayList(java.util.ArrayList) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)

Example 67 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class MaintenanceModeValidationService method handleValidationSuccess.

public void handleValidationSuccess(Long stackId, List<Warning> warnings) {
    LOGGER.debug("Maintenance mode validation flow has been finished successfully");
    stackUpdater.updateStackStatus(stackId, DetailedStackStatus.MAINTENANCE_MODE_ENABLED, "Validation has been finished");
    try {
        if (!warnings.isEmpty()) {
            String warningJson = new ObjectMapper().writeValueAsString(warnings);
            LOGGER.warn(String.format("Found warnings: {%s}", warningJson));
            flowMessageService.fireEventAndLog(stackId, AVAILABLE.name(), MAINTENANCE_MODE_VALIDATION_FINISHED_FOUND_WARNINGS, warningJson);
        } else {
            flowMessageService.fireEventAndLog(stackId, AVAILABLE.name(), MAINTENANCE_MODE_VALIDATION_FINISHED_NO_WARNINGS);
        }
    } catch (JsonProcessingException e) {
        throw new CloudbreakServiceException("Validation result could not be serialized!", e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 68 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class CmSyncHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<CmSyncRequest> event) {
    CmSyncRequest request = event.getData();
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        Set<Image> candidateImages = cmSyncImageCollectorService.collectImages(request.getFlowTriggerUserCrn(), stack, request.getCandidateImageUuids());
        CmSyncOperationSummary cmSyncOperationSummary = cmSyncerService.syncFromCmToDb(stack, candidateImages);
        CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationSummary.getSyncOperationStatus();
        if (!cmSyncOperationStatus.hasSucceeded()) {
            LOGGER.debug("Reading CM and active parcel versions from CM server encountered failures. Details: {}", cmSyncOperationStatus.getMessage());
            Exception e = new CloudbreakServiceException(cmSyncOperationStatus.getMessage());
            return new CmSyncResult(cmSyncOperationStatus.getMessage(), e, request);
        }
        return new CmSyncResult(request, cmSyncOperationStatus.getMessage());
    } catch (Exception e) {
        LOGGER.warn("Reading CM and active parcel versions from CM server resulted in error ", e);
        String message = String.format("unexpected error: %s", e.getMessage());
        return new CmSyncResult(message, new CloudbreakServiceException(message, e), request);
    }
}
Also used : CmSyncResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncResult) CmSyncOperationStatus(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus) CmSyncRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CmSyncOperationSummary(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 69 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class CmSyncHandler method defaultFailureEvent.

@Override
protected Selectable defaultFailureEvent(Long resourceId, Exception e, Event<CmSyncRequest> event) {
    LOGGER.debug("Reading CM and active parcel versions from CM server encountered an unexpected error ", e);
    String message = String.format("unexpected error: %s", e.getMessage());
    return new CmSyncResult(message, new CloudbreakServiceException(message, e), event.getData());
}
Also used : CmSyncResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncResult) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 70 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class DatalakeRecoveryBringupActions method datalakeRecoveryRestoreComponents.

@Bean(name = "RECOVERY_RESTORE_COMPONENTS_STATE")
public Action<?, ?> datalakeRecoveryRestoreComponents() {
    return new AbstractDatalakeRecoveryBringupAction<>(ClusterRecoveryTriggerEvent.class) {

        @Override
        protected void doExecute(DatalakeRecoveryBringupContext context, ClusterRecoveryTriggerEvent payload, Map<Object, Object> variables) {
            Long stackId = context.getStackId();
            try {
                Image image = componentConfigProviderService.getImage(stackId);
                imageComponentUpdaterService.updateForUpgrade(image.getImageId(), stackId);
            } catch (CloudbreakImageNotFoundException e) {
                String message = "Image was not found for current stack, it is not possible to continue recovery. " + "Please open a Cloudera support ticket to fix this issue";
                LOGGER.warn(message);
                throw new CloudbreakServiceException(message);
            }
            sendEvent(context, RECOVERY_RESTORE_COMPONENTS_FINISHED_EVENT.event(), payload);
        }
    };
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ClusterRecoveryTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterRecoveryTriggerEvent) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)142 Test (org.junit.jupiter.api.Test)25 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 List (java.util.List)20 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)18 IOException (java.io.IOException)18 Map (java.util.Map)18 ApiException (com.cloudera.api.swagger.client.ApiException)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)15 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)14 LoggerFactory (org.slf4j.LoggerFactory)14 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)12 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)12 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)12 Optional (java.util.Optional)12 Set (java.util.Set)12