Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offline_timeout_max option to control offline interval backoff #5252

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/confdb/confdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
#define CONFDB_DOMAIN_PWD_EXPIRATION_WARNING "pwd_expiration_warning"
#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_SUBDOMAIN_INHERIT "subdomain_inherit"
#define CONFDB_DOMAIN_CACHED_AUTH_TIMEOUT "cached_auth_timeout"
#define CONFDB_DOMAIN_TYPE "domain_type"
Expand Down
2 changes: 2 additions & 0 deletions src/config/SSSDConfigTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ def testListOptions(self):
'max_id',
'timeout',
'offline_timeout',
'offline_timeout_max',
'command',
'enumerate',
'cache_credentials',
Expand Down Expand Up @@ -969,6 +970,7 @@ def testRemoveProvider(self):
'max_id',
'timeout',
'offline_timeout',
'offline_timeout_max',
'command',
'enumerate',
'cache_credentials',
Expand Down
1 change: 1 addition & 0 deletions src/config/cfg_rules.ini
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ option = timeout
option = enumerate
option = subdomain_enumerate
option = offline_timeout
option = offline_timeout_max
option = cache_credentials
option = cache_credentials_minimal_first_factor_length
option = use_fully_qualified_names
Expand Down
1 change: 1 addition & 0 deletions src/config/etc/sssd.api.conf
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ timeout = int, None, false
enumerate = bool, None, false
subdomain_enumerate = str, None, false
offline_timeout = int, None, false
offline_timeout_max = int, None, false
cache_credentials = bool, None, false
cache_credentials_minimal_first_factor_length = int, None, false
use_fully_qualified_names = bool, None, false
Expand Down
28 changes: 25 additions & 3 deletions src/man/sssd.conf.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -783,15 +783,37 @@
</para>
<para>
Note that the maximum length of each interval
is currently limited to one hour. If the
calculated length of new_interval is greater
than an hour, it will be forced to one hour.
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.
</para>
<para>
Default: 60
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>offline_timeout_max (integer)</term>
<listitem>
<para>
Controls by how much the time between attempts to go
online can be incremented following unsuccessful
attempts to go online.
</para>
<para>
A value of 0 disables the incrementing behaviour.
</para>
<para>
Although a value between 0 and offline_timeout may be
specified, it has the effect of overriding the
offline_timeout value so is of little use.
</para>
<para>
Default: 3600
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>responder_idle_timeout</term>
<listitem>
Expand Down
8 changes: 4 additions & 4 deletions src/providers/be_ptask.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ static void be_ptask_schedule(struct be_ptask *task,
return;
}

delay = task->period;

if (backoff_allowed(task) && task->period * 2 <= task->max_backoff) {
if (backoff_allowed(task)) {
/* double the period for the next execution */
task->period *= 2;
task->period = MIN(task->period * 2, task->max_backoff);
}

delay = task->period;
break;
}

Expand Down
33 changes: 29 additions & 4 deletions src/providers/data_provider_be.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#define ONLINE_CB_RETRY 3
#define ONLINE_CB_RETRY_MAX_DELAY 4

#define OFFLINE_TIMEOUT_DEFAULT 60
#define OFFLINE_TIMEOUT_MAX_DEFAULT 3600

/* sssd.service */
static errno_t
data_provider_res_init(TALLOC_CTX *mem_ctx,
Expand Down Expand Up @@ -98,21 +101,42 @@ static int get_offline_timeout(struct be_ctx *ctx)
int offline_timeout;

ret = confdb_get_int(ctx->cdb, ctx->conf_path,
CONFDB_DOMAIN_OFFLINE_TIMEOUT, 60,
CONFDB_DOMAIN_OFFLINE_TIMEOUT,
OFFLINE_TIMEOUT_DEFAULT,
&offline_timeout);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Failed to get offline_timeout from confdb. "
"Will use 60 seconds.\n");
offline_timeout = 60;
"Will use %d seconds.\n", OFFLINE_TIMEOUT_DEFAULT);
offline_timeout = OFFLINE_TIMEOUT_DEFAULT;
}

return offline_timeout;
}

static int get_offline_timeout_max(struct be_ctx *ctx)
{
int offline_timeout_max;
errno_t ret;

ret = confdb_get_int(ctx->cdb, ctx->conf_path,
CONFDB_DOMAIN_OFFLINE_TIMEOUT_MAX,
OFFLINE_TIMEOUT_MAX_DEFAULT,
&offline_timeout_max);
if (ret != EOK) {
DEBUG(SSSDBG_CONF_SETTINGS,
"Failed to get offline_timeout_max from confdb. "
"Will use %d seconds.\n", OFFLINE_TIMEOUT_MAX_DEFAULT);
offline_timeout_max = OFFLINE_TIMEOUT_MAX_DEFAULT;
}

return offline_timeout_max;
}

void be_mark_offline(struct be_ctx *ctx)
{
int offline_timeout;
int offline_timeout_max;
errno_t ret;

DEBUG(SSSDBG_TRACE_INTERNAL, "Going offline!\n");
Expand All @@ -126,11 +150,12 @@ void be_mark_offline(struct be_ctx *ctx)
DEBUG(SSSDBG_TRACE_INTERNAL, "Initialize check_if_online_ptask.\n");

offline_timeout = get_offline_timeout(ctx);
deastoe marked this conversation as resolved.
Show resolved Hide resolved
offline_timeout_max = get_offline_timeout_max(ctx);

ret = be_ptask_create_sync(ctx, ctx,
offline_timeout, offline_timeout,
offline_timeout, 30, offline_timeout,
3600 /* max_backoff */,
offline_timeout_max,
try_to_go_online,
ctx, "Check if online (periodic)",
BE_PTASK_OFFLINE_EXECUTE,
Expand Down