Skip to content

fix: [OCISDEV-1360] Cache LDAP instance mapper lookups - #12898

Merged
2403905 merged 1 commit into
stable-8.2from
backport/8.2/OCISDEV-1360
Sep 11, 2026
Merged

2403905 merged 1 commit into
stable-8.2from
backport/8.2/OCISDEV-1360

Conversation

@2403905

@2403905 2403905 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Issue:
Uncached N+1 LDAP lookup during user listing in the graph service's LDAP identity backend, triggered by the multi-tenant/instance-mapper configuration.

Call chain
GET /graph/v1.0/users → Graph.GetUsers (services/graph/pkg/service/v0/users.go:316) → LDAP.GetUsers → LDAP.FilterUsers (services/graph/pkg/identity/ldap.go:761/766) — one LDAP search returns the whole page of users.
usersFromLDAPEntries (ldap.go:823) loops over every returned user and calls createUserModelFromLDAP per entry.
Because instanceURLTemplate/crossInstanceReferenceTemplate are configured, createUserModelFromLDAP (ldap.go:1061-1122) loops over each user's instance/guest attribute values and, for each one, calls getInstanceName → getInstance (ldap.go:1602/1616), which fires a brand-new LDAP Search to resolve the tenant/instance name.
getInstance has no cache — every call goes straight to LDAP (unlike other identity lookups in services/graph/pkg/identity/cache.go, which are cached).
Several referenced instance/member DNs don't resolve (stale data, recur every ~1s), so those lookups fail with itemnotfound — but still cost a full LDAP round-trip.
Net effect: a single GET /graph/v1.0/users call turns into N (users per page) × M (instance attrs per user) synchronous, uncached LDAP round-trips. Under 100 concurrent VUs this saturates the LDAP connection pool.

Bugfix: Cache LDAP instance mapper lookups
In multi-instance deployments, resolving a user's instance name/ID during
GET /graph/v1.0/users (and group member expansion) issued a fresh, uncached
LDAP search per instance/guest attribute value on every request. Under load
this multiplied into large numbers of redundant LDAP round-trips per page of
users, saturating the LDAP connection pool and causing request timeouts. The
LDAP identity backend now caches instance mapper lookups, including negative
(not-found) results, for a configurable TTL
(OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL, default 60s).

@kw-security

kw-security commented Sep 8, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@2403905
2403905 removed the request for review from a team September 8, 2026 07:14
@2403905
2403905 force-pushed the backport/8.2/OCISDEV-1360 branch from f42c49b to 0d1f7c2 Compare September 9, 2026 13:35
@2403905
2403905 merged commit 791a895 into stable-8.2 Sep 11, 2026
136 of 138 checks passed
@2403905
2403905 deleted the backport/8.2/OCISDEV-1360 branch September 11, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants