// TODO For now we only sync cloud ids during full sync. We should eventually allow more granular syncs (actor level and group level sync).
public SyncStatusDetail synchronizeStack(Stack stack, UmsUsersState umsUsersState, UserSyncOptions options) {
        MDCBuilder.buildMdcContext(stack);
        String environmentCrn = stack.getEnvironmentCrn();
        Multimap<String, String> warnings = ArrayListMultimap.create();
        try {
            FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack);
            UsersStateDifference usersStateDifferenceBeforeSync = compareUmsAndFreeIpa(umsUsersState, options, freeIpaClient);
            stateApplier.applyDifference(umsUsersState, environmentCrn, warnings, usersStateDifferenceBeforeSync, options, freeIpaClient);
            retrySyncIfBatchCallHasWarnings(stack, umsUsersState, warnings, options, freeIpaClient, usersStateDifferenceBeforeSync);
            if (options.isFullSync()) {
                // TODO For now we only sync cloud ids during full sync. We should eventually allow more granular syncs (actor level and group level sync).
                if (entitlementService.cloudIdentityMappingEnabled(stack.getAccountId())) {
                    LOGGER.debug("Starting {} ...", SYNC_CLOUD_IDENTITIES);
                    cloudIdentitySyncService.syncCloudIdentities(stack, umsUsersState, warnings::put);
                    LOGGER.debug("Finished {}.", SYNC_CLOUD_IDENTITIES);
                }
                if (entitlementService.isEnvironmentPrivilegedUserEnabled(stack.getAccountId())) {
                    LOGGER.debug("Starting {} ...", ADD_SUDO_RULES);
                    try {
                        sudoRuleService.setupSudoRule(stack, freeIpaClient);
                    } catch (Exception e) {
                        warnings.put(stack.getEnvironmentCrn(), e.getMessage());
                        LOGGER.error("{} failed for environment '{}'.", ADD_SUDO_RULES, stack.getEnvironmentCrn(), e);
                    }
                    LOGGER.debug("Finished {}.", ADD_SUDO_RULES);
                }
            }
            return toSyncStatusDetail(environmentCrn, warnings);
        } catch (TimeoutException e) {
            LOGGER.warn("Timed out while synchronizing environment {}", environmentCrn, e);
            return SyncStatusDetail.fail(environmentCrn, "Timed out", warnings);
        } catch (Exception e) {
            LOGGER.warn("Failed to synchronize environment {}", environmentCrn, e);
            return SyncStatusDetail.fail(environmentCrn, e.getLocalizedMessage(), warnings);
        }
    }
retrySyncIfBatchCallHasWarnings(stack, umsUsersState, warnings, options, freeIpaClient, usersStateDifferenceBeforeSync);
if (options.isFullSync()) {
// TODO For now we only sync cloud ids during full sync. We should eventually allow more granular syncs (actor level and group level sync).
if (entitlementService.cloudIdentityMappingEnabled(stack.getAccountId())) {
LOGGER.debug("Starting {} ...", SYNC_CLOUD_IDENTITIES);
public SyncStatusDetail synchronizeStack(Stack stack, UmsUsersState umsUsersState, UserSyncOptions options) {
MDCBuilder.buildMdcContext(stack);
String environmentCrn = stack.getEnvironmentCrn();
Multimap<String, String> warnings = ArrayListMultimap.create();
try {
FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack);
UsersStateDifference usersStateDifferenceBeforeSync = compareUmsAndFreeIpa(umsUsersState, options, freeIpaClient);
stateApplier.applyDifference(umsUsersState, environmentCrn, warnings, usersStateDifferenceBeforeSync, options, freeIpaClient);
retrySyncIfBatchCallHasWarnings(stack, umsUsersState, warnings, options, freeIpaClient, usersStateDifferenceBeforeSync);
if (options.isFullSync()) {
// TODO For now we only sync cloud ids during full sync. We should eventually allow more granular syncs (actor level and group level sync).
if (entitlementService.cloudIdentityMappingEnabled(stack.getAccountId())) {
LOGGER.debug("Starting {} ...", SYNC_CLOUD_IDENTITIES);
cloudIdentitySyncService.syncCloudIdentities(stack, umsUsersState, warnings::put);
LOGGER.debug("Finished {}.", SYNC_CLOUD_IDENTITIES);
}
if (entitlementService.isEnvironmentPrivilegedUserEnabled(stack.getAccountId())) {
LOGGER.debug("Starting {} ...", ADD_SUDO_RULES);
try {
sudoRuleService.setupSudoRule(stack, freeIpaClient);
} catch (Exception e) {
public SyncStatusDetail synchronizeStack(Stack stack, UmsUsersState umsUsersState, UserSyncOptions options) {
MDCBuilder.buildMdcContext(stack);
String environmentCrn = stack.getEnvironmentCrn();
Multimap<String, String> warnings = ArrayListMultimap.create();
try {
FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack);
UsersStateDifference usersStateDifferenceBeforeSync = compareUmsAndFreeIpa(umsUsersState, options, freeIpaClient);
stateApplier.applyDifference(umsUsersState, environmentCrn, warnings, usersStateDifferenceBeforeSync, options, freeIpaClient);
retrySyncIfBatchCallHasWarnings(stack, umsUsersState, warnings, options, freeIpaClient, usersStateDifferenceBeforeSync);
if (options.isFullSync()) {
// TODO For now we only sync cloud ids during full sync. We should eventually allow more granular syncs (actor level and group level sync).
if (entitlementService.cloudIdentityMappingEnabled(stack.getAccountId())) {
LOGGER.debug("Starting {} ...", SYNC_CLOUD_IDENTITIES);
cloudIdentitySyncService.syncCloudIdentities(stack, umsUsersState, warnings::put);
LOGGER.debug("Finished {}.", SYNC_CLOUD_IDENTITIES);
}
if (entitlementService.isEnvironmentPrivilegedUserEnabled(stack.getAccountId())) {
LOGGER.debug("Starting {} ...", ADD_SUDO_RULES);
try {
sudoRuleService.setupSudoRule(stack, freeIpaClient);
} catch (Exception e) {
warnings.put(stack.getEnvironmentCrn(), e.getMessage());
LOGGER.error("{} failed for environment '{}'.", ADD_SUDO_RULES, stack.getEnvironmentCrn(), e);
}
LOGGER.debug("Finished {}.", ADD_SUDO_RULES);
}
}
return toSyncStatusDetail(environmentCrn, warnings);
} catch (TimeoutException e) {
LOGGER.warn("Timed out while synchronizing environment {}", environmentCrn, e);
return SyncStatusDetail.fail(environmentCrn, "Timed out", warnings);