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

Fix leaking goroutines in QuotaEvaluator #110246

Merged
merged 1 commit into from May 27, 2022

Conversation

wojtek-t
Copy link
Member

Ref #108483

NONE

/kind cleanup
/priority important-longterm
/sig api-machinery

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 27, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wojtek-t

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver labels May 27, 2022
@k8s-ci-robot k8s-ci-robot requested review from ncdc and sttts May 27, 2022 06:15
// and often not started for some of those (e.g. aggregated apiserver)
// we explicitly shut it down on stopCh signal even if it wasn't
// effectively started.
go evaluator.shutdownOnStop()
Copy link
Member

Choose a reason for hiding this comment

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

does it means we start only once but we shutdown multiple times?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry - maybe I wasn't clear.
What I meant is that:

  • we create a separate QuotaEvaluator for every layer (separate for kube-apiserver, separate for agregated, separate for apiextensions)
  • the creation of it actually creates a queue which starts a goroutine that is updating metrics (this is created in line 125 so once per quota evaluator)
  • the newly added shutdownOnStop is also created here so called exactly once (per QuotaEvaluator)
  • the start() is called at most once - line 606

Copy link
Member

Choose a reason for hiding this comment

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

and why is not valid to keep it as it was?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure I understand the question.

As I wrote above - when I create QuotaEvaluator, this is underneath starting a gorotuine (created by workqueue.NewNamed).
That goroutine is shut down only when run() (renamed to start()) method is called.

run() is called on the first Evaluate - if that is not called - the goroutine will be leaked.

Copy link
Member

Choose a reason for hiding this comment

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

ahhhhhhhhhhhhhhhhhhhhhhhh ... sorry friday and lack coffeeeeeee

@aojea
Copy link
Member

aojea commented May 27, 2022

/lgtm
🙃

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2022
@k8s-ci-robot k8s-ci-robot merged commit 6c2265c into kubernetes:master May 27, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 27, 2022
@leilajal
Copy link
Contributor

leilajal commented Jun 2, 2022

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 2, 2022
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. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants