URL: https://github.com/SSSD/sssd/pull/5549 Author: elkoniu Title: #5549: data_provider: Configure backend probing interval Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/5549/head:pr5549 git checkout pr5549
From 276a86d5f2ecbfd95c98e94fe13ebb3ba8c25af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Po=C5=82awski?= <[email protected]> Date: Tue, 23 Mar 2021 14:40:46 +0100 Subject: [PATCH] data_provider: Configure backend probing interval When be_ptask is created to monitor backend when SSSD is in offline mode checks are happening in specified intervals: delay = delay + (sss_rand() % task->random_offset); New configuration option is introduced in this commit: * refresh_max_random_offset Using this option allows end client to decide what should be the size of random offset when new interval for probing backend is calculated. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1925608 --- src/confdb/confdb.h | 1 + src/config/SSSDConfigTest.py | 2 ++ src/config/cfg_rules.ini | 1 + src/config/etc/sssd.api.conf | 1 + src/man/sssd.conf.5.xml | 50 +++++++++++++++++++++++--------- src/providers/data_provider_be.c | 25 ++++++++++++++-- 6 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h index a2be227ddd..9e6e7cc453 100644 --- a/src/confdb/confdb.h +++ b/src/confdb/confdb.h @@ -245,6 +245,7 @@ #define CONFDB_DOMAIN_REFRESH_EXPIRED_INTERVAL "refresh_expired_interval" #define CONFDB_DOMAIN_OFFLINE_TIMEOUT "offline_timeout" #define CONFDB_DOMAIN_OFFLINE_TIMEOUT_MAX "offline_timeout_max" +#define CONFDB_DOMAIN_REFRESH_MAX_RANDOM_OFFSET "refresh_max_random_offset" #define CONFDB_DOMAIN_SUBDOMAIN_INHERIT "subdomain_inherit" #define CONFDB_DOMAIN_CACHED_AUTH_TIMEOUT "cached_auth_timeout" #define CONFDB_DOMAIN_TYPE "domain_type" diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py index 04c4b35baa..e13f804c50 100755 --- a/src/config/SSSDConfigTest.py +++ b/src/config/SSSDConfigTest.py @@ -594,6 +594,7 @@ def testListOptions(self): 'timeout', 'offline_timeout', 'offline_timeout_max', + 'refresh_max_random_offset', 'command', 'enumerate', 'cache_credentials', @@ -976,6 +977,7 @@ def testRemoveProvider(self): 'timeout', 'offline_timeout', 'offline_timeout_max', + 'refresh_max_random_offset', 'command', 'enumerate', 'cache_credentials', diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini index bf2d03b824..a931413e03 100644 --- a/src/config/cfg_rules.ini +++ b/src/config/cfg_rules.ini @@ -409,6 +409,7 @@ option = enumerate option = subdomain_enumerate option = offline_timeout option = offline_timeout_max +option = refresh_max_random_offset option = cache_credentials option = cache_credentials_minimal_first_factor_length option = use_fully_qualified_names diff --git a/src/config/etc/sssd.api.conf b/src/config/etc/sssd.api.conf index 49ced63859..2555519ade 100644 --- a/src/config/etc/sssd.api.conf +++ b/src/config/etc/sssd.api.conf @@ -172,6 +172,7 @@ enumerate = bool, None, false subdomain_enumerate = str, None, false offline_timeout = int, None, false offline_timeout_max = int, None, false +refresh_max_random_offset = int, None, false cache_credentials = bool, None, false cache_credentials_minimal_first_factor_length = int, None, false use_fully_qualified_names = bool, None, false diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml index 42659dffe6..dd87e4c40f 100644 --- a/src/man/sssd.conf.5.xml +++ b/src/man/sssd.conf.5.xml @@ -733,26 +733,24 @@ When SSSD switches to offline mode the amount of time before it tries to go back online will increase based upon the time spent disconnected. - This value is in seconds and calculated by the - following: - </para> - <para> - offline_timeout + random_offset - </para> - <para> - The random offset value is from 0 to 30. + By default SSSD uses incremental behaviour to + calculate delay in between retries. + The longer backend is offline, the bigger delays + in between attempts to checking it status again. After each unsuccessful attempt to go online, the new interval is recalculated by the following: </para> <para> - new_interval = (old_interval * 2) + random_offset + delay = (delay * 2) % offline_timeout_max + (rand() % refresh_max_random_offset) + </para> + <para> + The refresh_max_random_offset default value is 30. + The offline_timeout_max default value is 3600. + The end result is amount of seconds before next retry. </para> <para> Note that the maximum length of each interval - is defined by offline_timeout_max, which defaults - to one hour. If the calculated length of new_interval - is greater than offline_timeout_max, it will be forced - to the offline_timeout_max value. + is defined by offline_timeout_max (apart of random part). </para> <para> Default: 60 @@ -790,6 +788,32 @@ </para> </listitem> </varlistentry> + <varlistentry> + <term>refresh_max_random_offset (integer)</term> + <listitem> + <para> + When SSSD is in offline mode it keeps probing + backend servers in specified time intervals: + </para> + <para> + delay = (delay * 2) % offline_timeout_max + (rand() % refresh_max_random_offset) + </para> + <para> + This parameter controls the value of the random offset + used for above equation. Final random_offset value + will be random number in range: + </para> + <para> + [0 - refresh_max_random_offset] + </para> + <para> + A value of 0 disables the random offset addition. + </para> + <para> + Default: 30 + </para> + </listitem> + </varlistentry> <varlistentry> <term>responder_idle_timeout</term> <listitem> diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index e3f8c71c5a..101ae4ac5d 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -51,7 +51,7 @@ #define ONLINE_CB_RETRY 3 #define ONLINE_CB_RETRY_MAX_DELAY 4 -#define OFFLINE_TIMEOUT_RANDOM_OFFSET 30 +#define OFFLINE_TIMEOUT_RANDOM_OFFSET_DEFAULT 30 #define OFFLINE_TIMEOUT_DEFAULT 60 #define OFFLINE_TIMEOUT_MAX_DEFAULT 3600 @@ -134,10 +134,30 @@ static int get_offline_timeout_max(struct be_ctx *ctx) return offline_timeout_max; } +static int get_offline_timeout_random_offset(struct be_ctx *ctx) +{ + int offline_timeout_random_offset; + errno_t ret; + + ret = confdb_get_int(ctx->cdb, ctx->conf_path, + CONFDB_DOMAIN_REFRESH_MAX_RANDOM_OFFSET, + OFFLINE_TIMEOUT_RANDOM_OFFSET_DEFAULT, + &offline_timeout_random_offset); + if (ret != EOK) { + DEBUG(SSSDBG_CONF_SETTINGS, + "Failed to get refresh_max_random_offset from confdb. " + "Will use %d seconds.\n", OFFLINE_TIMEOUT_RANDOM_OFFSET_DEFAULT); + offline_timeout_random_offset = OFFLINE_TIMEOUT_RANDOM_OFFSET_DEFAULT; + } + + return offline_timeout_random_offset; +} + void be_mark_offline(struct be_ctx *ctx) { int offline_timeout; int offline_timeout_max; + int offline_timeout_random_offset; errno_t ret; DEBUG(SSSDBG_TRACE_INTERNAL, "Going offline!\n"); @@ -152,13 +172,14 @@ void be_mark_offline(struct be_ctx *ctx) offline_timeout = get_offline_timeout(ctx); offline_timeout_max = get_offline_timeout_max(ctx); + offline_timeout_random_offset = get_offline_timeout_random_offset(ctx); ret = be_ptask_create_sync(ctx, ctx, offline_timeout, offline_timeout, offline_timeout, - OFFLINE_TIMEOUT_RANDOM_OFFSET, + offline_timeout_random_offset, offline_timeout, offline_timeout_max, try_to_go_online,
_______________________________________________ sssd-devel mailing list -- [email protected] To unsubscribe send an email to [email protected] Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/[email protected] Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
