Search in sources :

Example 31 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class UpgradeCcmService method failedState.

public void failedState(UpgradeCcmContext context, UpgradeCcmFailureEvent payload) {
    InMemoryStateStore.deleteStack(payload.getResourceId());
    DetailedStackStatus detailedStatus = payload.getTransitionStatusAfterFailure().orElse(UPGRADE_CCM_FAILED);
    String statusReason = "Upgrade CCM failed";
    stackUpdater.updateStackStatus(payload.getResourceId(), detailedStatus, statusReason);
}
Also used : DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)

Example 32 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaScalingServiceTest method testDownscaleIfValidationFailsThenErrorThrown.

@Test
public void testDownscaleIfValidationFailsThenErrorThrown() {
    Stack stack = mock(Stack.class);
    Set<InstanceMetaData> allInstances = createValidImSet();
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
    DownscaleRequest request = createDownscaleRequest();
    doThrow(new BadRequestException("validation failed")).when(validationService).validateStackForDownscale(allInstances, stack, new ScalingPath(AvailabilityType.TWO_NODE_BASED, AvailabilityType.NON_HA));
    BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.downscale(ACCOUNT_ID, request));
    assertEquals(exception.getMessage(), "validation failed");
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) DownscaleRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleRequest) ScalingPath(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 33 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class UserSyncStatusToUserSyncStatusResponseConverter method convert.

@Override
public UserSyncStatusResponse convert(UserSyncStatus userSyncStatus) {
    UserSyncStatusResponse response = new UserSyncStatusResponse();
    Optional.ofNullable(userSyncStatus.getLastStartedFullSync()).ifPresent(op -> response.setLastStartedUserSyncId(op.getOperationId()));
    Optional.ofNullable(userSyncStatus.getLastSuccessfulFullSync()).ifPresent(op -> response.setLastSuccessfulUserSyncId(op.getOperationId()));
    Optional.ofNullable(userSyncStatus.getUmsEventGenerationIds()).ifPresent(eids -> {
        try {
            response.setEventGenerationIds(eids.get(UmsEventGenerationIds.class).getEventGenerationIds());
        } catch (IOException e) {
            LOGGER.warn("Failed to convert event generation ids [{}] for environment '{}'", userSyncStatus.getUmsEventGenerationIds(), userSyncStatus.getStack().getEnvironmentCrn());
        }
    });
    return response;
}
Also used : UserSyncStatusResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.usersync.UserSyncStatusResponse) IOException(java.io.IOException)

Example 34 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaCreationService method launchFreeIpa.

public DescribeFreeIpaResponse launchFreeIpa(CreateFreeIpaRequest request, String accountId) {
    String userCrn = crnService.getUserCrn();
    Future<String> ownerFuture = initiateOwnerFetching(userCrn);
    Credential credential = credentialService.getCredentialByEnvCrn(request.getEnvironmentCrn());
    DetailedEnvironmentResponse environment = measure(() -> cachedEnvironmentClientService.getByCrn(request.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn());
    Stack stack = stackConverter.convert(request, environment, accountId, ownerFuture, userCrn, credential.getCloudPlatform());
    stack.setAppVersion(appVersion);
    GetPlatformTemplateRequest getPlatformTemplateRequest = templateService.triggerGetTemplate(stack, credential);
    Telemetry telemetry = stack.getTelemetry();
    if (telemetry != null) {
        telemetry.setRules(accountTelemetryService.getAnonymizationRules(accountId));
    }
    cloudStorageFolderResolverService.updateStorageLocation(telemetry, FluentClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
    stack.setTelemetry(telemetry);
    Backup backup = stack.getBackup();
    backup = cloudBackupFolderResolverService.updateStorageLocation(backup, BackupClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
    stack.setBackup(backup);
    fillInstanceMetadata(stack, environment);
    String template = templateService.waitGetTemplate(getPlatformTemplateRequest);
    stack.setTemplate(template);
    SecurityConfig securityConfig = tlsSecurityService.generateSecurityKeys(accountId);
    multiAzValidator.validateMultiAzForStack(stack.getPlatformvariant(), stack.getInstanceGroups());
    freeIpaRecommendationService.validateCustomInstanceType(stack, credential);
    try {
        Triple<Stack, ImageEntity, FreeIpa> stackImageFreeIpaTuple = transactionService.required(() -> {
            SecurityConfig savedSecurityConfig = securityConfigService.save(securityConfig);
            stack.setSecurityConfig(savedSecurityConfig);
            Stack savedStack = stackService.save(stack);
            ImageSettingsRequest imageSettingsRequest = request.getImage();
            ImageEntity image = imageService.create(savedStack, Objects.nonNull(imageSettingsRequest) ? imageSettingsRequest : new ImageSettingsRequest());
            FreeIpa freeIpa = freeIpaService.create(savedStack, request.getFreeIpa());
            return Triple.of(savedStack, image, freeIpa);
        });
        flowManager.notify(FlowChainTriggers.PROVISION_TRIGGER_EVENT, new StackEvent(FlowChainTriggers.PROVISION_TRIGGER_EVENT, stackImageFreeIpaTuple.getLeft().getId()));
        InMemoryStateStore.putStack(stack.getId(), PollGroup.POLLABLE);
        return stackToDescribeFreeIpaResponseConverter.convert(stackImageFreeIpaTuple.getLeft(), stackImageFreeIpaTuple.getMiddle(), stackImageFreeIpaTuple.getRight(), Optional.empty(), false);
    } catch (TransactionService.TransactionExecutionException e) {
        LOGGER.error("Creation of FreeIPA failed", e);
        throw new BadRequestException("Creation of FreeIPA failed: " + e.getCause().getMessage(), e);
    }
}
Also used : Credential(com.sequenceiq.freeipa.dto.Credential) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) Backup(com.sequenceiq.freeipa.api.model.Backup) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.freeipa.entity.Stack) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) SecurityConfig(com.sequenceiq.freeipa.entity.SecurityConfig) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) GetPlatformTemplateRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateRequest)

Example 35 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method createBindUser.

private void createBindUser(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        BindUserCreateRequest bindUserCreateRequest = new BindUserCreateRequest();
        bindUserCreateRequest.setEnvironmentCrn(environmentCrn);
        bindUserCreateRequest.setBindUserNameSuffix("testuser");
        String initiatorUserCrn = "__internal__actor__";
        OperationStatus operationStatus = ipaClient.getFreeIpaV1Endpoint().createE2ETestBindUser(bindUserCreateRequest, initiatorUserCrn);
        waitToCompleted(testContext, operationStatus.getOperationId(), "createBindUserOperation");
    } catch (Exception e) {
        logger.error("CREATE BIND USER test failed during upgrade", e);
        throw new TestFailException("CREATE BIND USER test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest) OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)12 WebApplicationException (javax.ws.rs.WebApplicationException)11 FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)9 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)9 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Map (java.util.Map)7 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)6 Bean (org.springframework.context.annotation.Bean)6 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)5 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)4 FlowParameters (com.sequenceiq.flow.core.FlowParameters)4 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)4 StateContext (org.springframework.statemachine.StateContext)4 Flow (com.sequenceiq.flow.core.Flow)3 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)3 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)3 Test (org.junit.jupiter.api.Test)3 ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)2