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

🐛 Memory leak fix in mutating & validating webhooks #3026

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

mjudeikis
Copy link
Contributor

Summary

Each time informer.Informer().AddEventHandler is called go routine is spanned to monitor the event.
configuration.NewMutatingWebhookConfigurationManagerForInformer does just that so each time plugin.Admit is called we span a go routine. And so it infinity;
image

Related issue(s)

Fixes #3016

Release Notes

NONE

@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 13, 2023
@mjudeikis mjudeikis requested a review from sttts October 13, 2023 13:36
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 13, 2023
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 848ff26f77c7ecd62711cbd39ce3eaad77d8a2ab

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

Do you need locking? Is getHookSource called for requests in separate goroutines?

@kcp-ci-bot kcp-ci-bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 13, 2023
@kcp-ci-bot kcp-ci-bot requested a review from embik October 13, 2023 13:46
@mjudeikis
Copy link
Contributor Author

mjudeikis commented Oct 13, 2023

Do you need locking? Is getHookSource called for requests in separate goroutines?

Yes, Initially I thought it might be ok todo optimistic concurrency as its assignments (override basically) and reads but better safe than sorry

@mjudeikis
Copy link
Contributor Author

/retest

2 similar comments
@mjudeikis
Copy link
Contributor Author

/retest

@mjudeikis
Copy link
Contributor Author

/retest

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 16, 2023
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 09f965cde2d66fc80f81f87ecdbe95c59c9a9a78

@mjudeikis
Copy link
Contributor Author

ping @sttts

@@ -54,6 +55,9 @@ type Plugin struct {
globalKubeSharedInformerFactory kcpkubernetesinformers.SharedInformerFactory

getAPIBindings func(clusterName logicalcluster.Name) ([]*apisv1alpha1.APIBinding, error)

managerLock sync.Mutex
managersCache map[logicalcluster.Name]generic.Source
Copy link
Member

Choose a reason for hiding this comment

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

this also means that nobody cleans those up when a logical cluster is gone, right? Maybe not as bad.

Copy link
Member

Choose a reason for hiding this comment

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

Some ttl could help. If there is no request for 5min, remove them.

@sttts
Copy link
Member

sttts commented Oct 16, 2023

/approve

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik, sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 16, 2023
@kcp-ci-bot kcp-ci-bot merged commit f1a70e6 into kcp-dev:main Oct 16, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: leaking memory and goroutines
5 participants