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

client-go: support Shutdown() for metadata and dynamic informers #114434

Merged

Conversation

howardjohn
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Followup to #112200, specifically #112200 (comment).

Special notes for your reviewer:

Does this PR introduce a user-facing change?

client-go: metadatainformer and dynamicinformer `SharedInformerFactory`s now supports waiting for goroutines during shutdown

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 12, 2022
@howardjohn
Copy link
Contributor Author

cc @pohly

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 12, 2022
@apelisse
Copy link
Member

cc @alexzielenski

@apelisse
Copy link
Member

/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 Dec 13, 2022
@@ -27,6 +27,7 @@ type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
ForResource(gvr schema.GroupVersionResource) informers.GenericInformer
WaitForCacheSync(stopCh <-chan struct{}) map[schema.GroupVersionResource]bool
Shutdown()
Copy link
Member

Choose a reason for hiding this comment

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

naive by-stander question, why do we need a shutdown when starts already takes a stopCh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The shutdown additionally actually waits for everything to terminate is the difference

Copy link
Contributor

Choose a reason for hiding this comment

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

It would make sense to copy the documentation from https://github.com/kubernetes/kubernetes/pull/112200/files, then someone (like @apelisse) who looks at this interface can see how to use it without having to know that some other, similar interface elsewhere explains it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, copy+pasted from your PR. thanks

Copy link
Member

Choose a reason for hiding this comment

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

I'm not super excited about this API, one needs to keep two handles to shutdown a factory (the stopCh, AND the factory which is error-prone and smelly). I can also call shutdown on something that hasn't been created. I can shutdown but forget to close the channel (it will hang forever?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I had called the new function WaitForShutdown initially and then there were concerns about that name that led to a renaming 🤷

See #112200 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Maybe "RejectNewAndWaitForShutdown" at least captures what it actually does :(

Apologies for not spending more time on that review :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Normally we call the method "Run" instead of "Start" and you just wait for it to exit.

I agree that the most consistent thing to do here would be to expose a Run which blocks. Start could be refactored to call Run for backwards compatibility. Is that something people are interested in?

Copy link
Member

Choose a reason for hiding this comment

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

Alex, defining a Run sounds good to me. It's not clear without digging in if it is good to make one function call the other or not.

We should definitely leave the existing Start functions as-is behavior-wise to not break people.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think we can define Run to call Start and the now DOA Shutdown, that'd be a good API with minimal change.

@howardjohn
Copy link
Contributor Author

/retest

@pohly
Copy link
Contributor

pohly commented Dec 14, 2022

/retest

@howardjohn
Copy link
Contributor Author

/retest

@howardjohn
Copy link
Contributor Author

Given #114496 is closed can we move forward with this for consistency?

@alexzielenski
Copy link
Contributor

alexzielenski commented Feb 16, 2023

since this is the direction we are going for this API, this is looks good to me. I checked the changes against the original, and they are mirrored

/lgtm
/assign @lavalamp

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 16, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 5e03ccac06ade04754f48cb0bf5388bc4bc4d3c4

@lavalamp
Copy link
Member

/approve

for nits:
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 24, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: howardjohn, lavalamp

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 24, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2023
@howardjohn
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2023
@lavalamp
Copy link
Member

/label tide/merge-method-squash
/lgtm

@k8s-ci-robot k8s-ci-robot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Feb 28, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1c72024159e4b60f5c53439f1d3f6121b8ed4d3a

@k8s-triage-robot
Copy link

The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass.

This bot retests PRs for certain kubernetes repos according to the following rules:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

1 similar comment
@k8s-triage-robot
Copy link

The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass.

This bot retests PRs for certain kubernetes repos according to the following rules:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@k8s-ci-robot k8s-ci-robot merged commit b99fe0d into kubernetes:master Mar 1, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Mar 1, 2023
rayowang pushed a commit to rayowang/kubernetes that referenced this pull request Feb 9, 2024
…ubernetes#114434)

* client-go: support `Shutdown()` for metadata and dynamic informers

Followup to kubernetes#112200,
specifically
kubernetes#112200 (comment).

* add comments

* Defer lock
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. 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

7 participants