From 4d22dad757f3712629118e703dbc1bc0787a9e49 Mon Sep 17 00:00:00 2001 From: Artur Socha Date: Tue, 19 Apr 2022 10:11:04 +0200 Subject: [PATCH] Configurable kcadm config delay This patch makes a configuration delay more flexible to avoid unnecessary long delays on more powerful machines. The delay can now be set using OVE property ie. engine-setup --otopi-environment="OVESETUP_KEYCLOAK_CONFIG/configDelaySeconds=int:5" Signed-off-by: Artur Socha --- .../ovirt_engine_setup/keycloak/constants.py | 4 ++++ .../ovirt-engine-keycloak/core/ovirt_internal.py | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packaging/setup/ovirt_engine_setup/keycloak/constants.py b/packaging/setup/ovirt_engine_setup/keycloak/constants.py index 7aff248..e9435d8 100644 --- a/packaging/setup/ovirt_engine_setup/keycloak/constants.py +++ b/packaging/setup/ovirt_engine_setup/keycloak/constants.py @@ -70,6 +70,7 @@ class Const(object): KEYCLOAK_CLI_ADMIN_SCRIPT = 'kcadm.sh' OVIRT_ENGINE_KEYCLOAK_PACKAGE_NAME = 'ovirt-engine-keycloak' OVIRT_ENGINE_KEYCLOAK_SETUP_PACKAGE_NAME = 'ovirt-engine-keycloak-setup' + OVIRT_ENGINE_KEYCLOAK_CONFIG_DELAY_SECONDS = 10 @classproperty def KEYCLOAK_DB_ENV_KEYS(self): @@ -177,6 +178,9 @@ class CoreEnv(object): def ENABLE(self): return 'OVESETUP_KEYCLOAK_CORE/enable' + OVIRT_ENGINE_KEYCLOAK_CONFIG_DELAY = 'OVESETUP_KEYCLOAK_CONFIG/configDelaySeconds' + + @util.export @util.codegen @osetupattrsclass diff --git a/packaging/setup/plugins/ovirt-engine-common/ovirt-engine-keycloak/core/ovirt_internal.py b/packaging/setup/plugins/ovirt-engine-common/ovirt-engine-keycloak/core/ovirt_internal.py index 1ca44d2..26cf84b 100644 --- a/packaging/setup/plugins/ovirt-engine-common/ovirt-engine-keycloak/core/ovirt_internal.py +++ b/packaging/setup/plugins/ovirt-engine-common/ovirt-engine-keycloak/core/ovirt_internal.py @@ -31,12 +31,21 @@ class Plugin(plugin.PluginBase): """Ovirt engine keycloak internal sso realm configuration plugin.""" KCADM_ENV = { - 'KC_OPTS':'-Dcom.redhat.fips=false' + 'KC_OPTS': '-Dcom.redhat.fips=false' } def __init__(self, context): super(Plugin, self).__init__(context=context) + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + okkcons.CoreEnv.OVIRT_ENGINE_KEYCLOAK_CONFIG_DELAY, + okkcons.Const.OVIRT_ENGINE_KEYCLOAK_CONFIG_DELAY_SECONDS, + ) + @plugin.event( stage=plugin.Stages.STAGE_SETUP, ) @@ -78,7 +87,9 @@ def _setup_ovirt(self): # TODO sometimes keycloak app is not ready soon enough resulting # in 503 error on attempt to use kcadm.sh / api # This sleep is only a workaround until better way is found - time.sleep(30) + time.sleep(self.environment[ + okkcons.CoreEnv.OVIRT_ENGINE_KEYCLOAK_CONFIG_DELAY + ]) self._setup_keystore()