Search in sources :

Example 41 with UserSyncStatus

use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.

the class UserSyncPoller method syncFreeIpaStacksInAccount.

private void syncFreeIpaStacksInAccount(Optional<String> requestId, String accountId, List<Stack> stacks) {
    Instant cooldownThresholdTime = Instant.now().minus(cooldown);
    UmsEventGenerationIds currentGeneration = umsEventGenerationIdsProvider.getEventGenerationIds(accountId, requestId);
    stacks.forEach(stack -> {
        UserSyncStatus userSyncStatus = userSyncStatusService.getOrCreateForStack(stack);
        if (!eventGenerationIdsChecker.isInSync(userSyncStatus, currentGeneration) && cooldownChecker.isCooldownExpired(userSyncStatus, cooldownThresholdTime)) {
            LOGGER.debug("Environment {} in Account {} is not in sync.", stack.getEnvironmentCrn(), stack.getAccountId());
            Operation operation = userSyncService.synchronizeUsers(stack.getAccountId(), regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), Set.of(stack.getEnvironmentCrn()), Set.of(), Set.of(), WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED);
            LOGGER.debug("User Sync request resulted in operation {}", operation);
        } else {
            LOGGER.debug("Environment {} in Account {} is in sync or has been synchronized recently.", stack.getEnvironmentCrn(), stack.getAccountId());
        }
    });
}
Also used : UmsEventGenerationIds(com.sequenceiq.freeipa.service.freeipa.user.model.UmsEventGenerationIds) Instant(java.time.Instant) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation)

Aggregations

UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)41 Test (org.junit.jupiter.api.Test)30 Stack (com.sequenceiq.freeipa.entity.Stack)18 Operation (com.sequenceiq.freeipa.entity.Operation)17 UmsEventGenerationIds (com.sequenceiq.freeipa.service.freeipa.user.model.UmsEventGenerationIds)10 Json (com.sequenceiq.cloudbreak.common.json.Json)8 EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)7 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)6 OperationType (com.sequenceiq.freeipa.api.v1.operation.model.OperationType)5 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)4 SyncStatusDetail (com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail)4 Instant (java.time.Instant)4 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)2 UserSyncStatusResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.usersync.UserSyncStatusResponse)2 UmsUsersState (com.sequenceiq.freeipa.service.freeipa.user.model.UmsUsersState)2 Collection (java.util.Collection)2 Optional (java.util.Optional)2 Callable (java.util.concurrent.Callable)2