Skip to content

idp: do not update cache timeout if member is added#8545

Open
sumit-bose wants to merge 3 commits intoSSSD:masterfrom
sumit-bose:idp_group_fixes
Open

idp: do not update cache timeout if member is added#8545
sumit-bose wants to merge 3 commits intoSSSD:masterfrom
sumit-bose:idp_group_fixes

Conversation

@sumit-bose
Copy link
Copy Markdown
Contributor

If only a single member is added to a group, e.g. during an initgroups
request, do not increment the cache timeout because it is not clear if
the list of members is complete or not.

Resolve: #8330

conf: add avoid_id_lookups domain option

If this new option option is set to 'true' SSSD will try to avoid
sending lookups by ID to the backend and will switch to a lookup by name
if a cached object with a matching ID can be found. This option can
e.g. be used in cases where searches by ID are expensive on the server
side because of missing indexes or are not even possible.

:config: New option 'avoid_id_lookups' to tell the SSSD responders to
use a lookup by name instead of by id where possible

Resolves: #7668

@sumit-bose sumit-bose marked this pull request as ready for review March 23, 2026 18:46
@sumit-bose
Copy link
Copy Markdown
Contributor Author

sumit-bose commented Mar 23, 2026

Hi,

with respect to #8330 this PR only solves the id/getent group interaction. The handling of nested groups will be part of a different PR.

bye,
Sumit

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new configuration option, avoid_id_lookups, for SSSD domains. This option, which defaults to true for IdP providers, enables SSSD to optimize lookups by attempting to fall back to name-based searches when an ID-based lookup is performed and a cached object with a matching ID is found, thereby avoiding potentially expensive ID lookups on the backend. The changes include adding the configuration option to the domain structure, implementing the fallback logic in cache request processing, updating configuration files and documentation, and adding a new system test for IdP provider behavior. Additionally, an optimization was made in the IdP provider to prevent resetting group cache timeouts when only a single member is added. There are no review comments to address.

@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Mar 23, 2026
@alexey-tikhonov alexey-tikhonov self-assigned this Mar 23, 2026
@alexey-tikhonov alexey-tikhonov self-requested a review March 23, 2026 19:37
@alexey-tikhonov
Copy link
Copy Markdown
Member

python-system-tests fails.

@alexey-tikhonov
Copy link
Copy Markdown
Member

Imo, option name avoid_id_lookups is unfortunate as it relates to 'id_provider' in general.
Maybe avoid_by_id_lookups?

</para>
<para>
This option can e.g. be used in cases where
searches by ID are expensive on the server side
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this examlpe - "searches by ID are expensive" - realistic?
Maybe would be better to give (vague enough) examples for "not even possible" - non-reversible id-mapping (IIUC)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would explain "True for IdP provider" exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the man page entry.

goto done;
}


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why double new line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
}

if (strcasecmp(domain->provider, "idp") == 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels inconsistent that CONFDB_DOMAIN_AUTO_UPG handling checks for domain->provider != NULL and this check doesn't.

Given "Domain [%s] does not specify an ID provider, disabling!\n" above perhaps both aren't needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the NULL check is not needed and there is already another use of domain->provider without a check. Do you want to get the CONFDB_DOMAIN_AUTO_UPG case fixed here?

</varlistentry>

<varlistentry>
<term>avoid_id_lookups (boolean)</term>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional new option can't be listed in subdomain_inherit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

currently it is automatically inherited in new_subdomain(). I did this because even if there are sub-domains which can handle lookups by-id the fallback should do no harm and if the fallback is not possible the lookup by-id will be tried anyways.

bye,
Sumit

@alexey-tikhonov
Copy link
Copy Markdown
Member

"If this new option option is set ..." -- double 'option' in the commit message.


name = ldb_msg_find_attr_as_string(result->msgs[0], SYSDB_NAME, NULL);
if (name != NULL) {
ret = cache_req_set_plugin(cr, CACHE_REQ_GROUP_BY_NAME);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this hardcode CACHE_REQ_GROUP_BY_NAME?

Function can be called for "User by ID" plugin as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed


if (cr->domain->avoid_id_lookups
&& (strcmp(cr->plugin->name, "Group by ID") == 0
|| strcmp(cr->plugin->name, "User by ID") == 0)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to match against cache_req_data_get_type() - cheaper and less fragile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache_req_data_get_type() is used in the latest version.

cache_timeout = dom->group_timeout;
/* If we just add a single member to the group we do not want to change
* the cache timeout. */
cache_timeout = user_name == NULL ? dom->group_timeout : 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting '0' explicitly expires group object (if it already exists) -- this doesn't match comment "do not want to change the cache timeout".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is possible though...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I handled this differently in the latest version.

/* If we just add a single member to the group we do not want to change
* the cache timeout. */
cache_timeout = user_name == NULL ? dom->group_timeout : 0;
ret = sysdb_store_group(dom, fqdn, gid, attrs, cache_timeout, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, should this check ret != EOK?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@alexey-tikhonov
Copy link
Copy Markdown
Member

Commit message: "Resolve: #8330" -> "Resolves ..."

If this new option is set to 'true' SSSD will try to avoid sending
lookups by ID to the backend and will switch to a lookup by name if a
cached object with a matching ID can be found.  This option can e.g. be
used in cases where searches by ID are expensive on the server side
because of missing indexes or are not even possible.

:config: New option 'avoid_by_id_lookups' to tell the SSSD responders to
         use a lookup by name instead of by id where possible

Resolves: SSSD#7668
If 'avoid_by_id_lookups' is set to 'True' switch to a lookup by name if
a user or a group is searched by ID.

Resolves: SSSD#7668
If only a single member is added to a group, e.g. during an initgroups
request, do not increment the cache timeout because it is not clear if
the list of members is complete or not.

Resolves: SSSD#8330
@sumit-bose
Copy link
Copy Markdown
Contributor Author

Imo, option name avoid_id_lookups is unfortunate as it relates to 'id_provider' in general. Maybe avoid_by_id_lookups?

Hi,

I changed this in the latest version.

bye,
Sumit

@sumit-bose
Copy link
Copy Markdown
Contributor Author

"If this new option option is set ..." -- double 'option' in the commit message.

fixed

@sumit-bose
Copy link
Copy Markdown
Contributor Author

Commit message: "Resolve: #8330" -> "Resolves ..."

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only. Waiting for review

Projects

None yet

3 participants