Skip to content

fix(operator): drop identity mapping when allocator no longer knows the identity - #2910

Open
Vedant Burgul (burgulvedant) wants to merge 1 commit into
microsoft:mainfrom
burgulvedant:fix/identity-manager-stale-entry
Open

Vedant Burgul (burgulvedant) wants to merge 1 commit into
microsoft:mainfrom
burgulvedant:fix/identity-manager-stale-entry

Conversation

@burgulvedant

Copy link
Copy Markdown

Related to #2647 (partial fix, does not close it).

What
DecrementReference returned early when LookupIdentityByID found no identity, leaving the labelIdentities entry in the map for the lifetime of the process. If the allocator no longer has the identity there is nothing left to release, so this removes the mapping too.

Scope
This removes one source of stale entries. It is not shown to explain the full memory growth in #2647. The reporter still saw memory held after deleting all CiliumIdentities, so part of it may be in the allocator's local keys or the hourly SyncInterval.

Testing
Not run locally. The change is formatted with gofmt. No unit test is included because I could not confirm how the allocator reaches the state where the lookup returns nothing. Happy to add one if a maintainer can point me to a way to set that up.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@burgulvedant

Copy link
Copy Markdown
Author

Beegii Khurelsukh (@BeegiiK) orangejuice could one of you please run /azp run so the pipelines can start? Happy to fix anything they report.

@rbtr

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…he identity

DecrementReference returned early when LookupIdentityByID found no identity, leaving the labelIdentities entry in the map for the lifetime of the process. If the allocator no longer has the identity there is nothing left to release, so remove the mapping too.
@burgulvedant
Vedant Burgul (burgulvedant) force-pushed the fix/identity-manager-stale-entry branch from 973e3b7 to be301e7 Compare November 4, 2026 08:38
@burgulvedant

Copy link
Copy Markdown
Author

Evan Baker (@rbtr) thanks for running /azp run earlier. I have since rebased on main and signed the commit, so the branch is up to date and shows as Verified. Because the commit changed, could you approve the new GitHub Actions workflow runs and trigger /azp run once more? Beegii Khurelsukh (@BeegiiK) orangejuice when CI is green, a review would be appreciated. Happy to adjust the change if you want it done differently.

@mereta

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Deleting the identity mapping after a lookup miss can strand allocator-local references for Pods sharing an identity, so the release path must preserve the mapping until the final reference is released.

1 open issue
What changed in this PR

This PR targets one source of stale identity mappings in the operator as a partial fix for #2647; it does not claim to resolve the full reported memory growth.

Changes:

  • Deletes the label-to-identity mapping when DecrementReference cannot look up the identity.
  • Adds comments explaining the intended cleanup behavior.
File Description
pkg/​controllers/​operator/​cilium-crds/​endpoint/​identitymanager_linux.go Adds mapping cleanup to the identity lookup-miss branch.

Review effort: Balanced

Comment on lines +92 to 96
// The allocator no longer knows this identity, so there is nothing left to release.
// Drop our mapping too, otherwise it would be kept for the lifetime of the process.
im.l.Warn("expected identity for id", "identity", id)
delete(im.labelIdentities, sortedLabels)
return

This branch has not been deployed

No deployments
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.

4 participants