Skip to content

kube: cleanup crdwatcher a bit #44145

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

Merged
merged 2 commits into from
May 24, 2023

Conversation

howardjohn
Copy link
Member

@howardjohn howardjohn commented Mar 28, 2023

edit: lets do #44899 first, then I will rebase this.

This reworks how we enable optional watchers, which will watch only if the CRD is present.

Today, we do this a few different ways for variuous usages. This standardizes on a single implementation in kclient.

Clients can specify a "Delay" which will result in a client that may exist now or at some future point:

For example:

		wasm := kclient.NewFiltered[*istioclient.WasmPlugin](c, kubetypes.Filter{
			Delayed: crdwatcher.NewDelayedFilter(gvr.WasmPlugin, c.CrdWatcher()),
		})

Aside from the filter during creation, usage for this is completely transparent. The kclient will ensure that we only return HasSynced=true once the CRD is ready and we start watching OR the CrdWatcher has finished syncing and the CRD did not exist.

@howardjohn howardjohn added do-not-merge/hold Block automatic merging of a PR. release-notes-none Indicates a PR that does not require release notes. labels Mar 28, 2023
@howardjohn howardjohn requested review from a team as code owners March 28, 2023 23:55
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 28, 2023
@howardjohn
Copy link
Member Author

@hzxuzhonghu I put a hold sinec I am not 100% sure this is correct yet, going to self-review it a bit more tomorrow. But wanted to put it up for feedback

@hzxuzhonghu
Copy link
Member

Sorry for the delay i am a little busy with other work. Will take a look later

@hzxuzhonghu hzxuzhonghu self-assigned this Mar 29, 2023
Comment on lines 188 to 189
if !cl.crdWatcher.Known(s.GroupVersionResource()) {
cl.logger.Warnf("Skipping CRD %v as it is not present", s.GroupVersionKind())
Copy link
Member

Choose a reason for hiding this comment

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

The log skipping is confusing, maybe CRD xx is not yet present, will be handled latter once it is created

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

Generally it looks viable, previously we didnot check crdWatcher.hasSynced at all, which is not right.

@howardjohn howardjohn marked this pull request as draft March 30, 2023 14:48
@istio-testing istio-testing added the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Mar 30, 2023
@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from cc7fe87 to 5718d64 Compare April 11, 2023 01:23
@istio-testing istio-testing added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 11, 2023
@howardjohn
Copy link
Member Author

/test all

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label May 2, 2023
@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from 5718d64 to 340e844 Compare May 5, 2023 18:19
@howardjohn
Copy link
Member Author

/test all

@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label May 5, 2023
@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from 340e844 to 20f7745 Compare May 5, 2023 20:22
@howardjohn
Copy link
Member Author

/test all

@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from 20f7745 to a99f3fb Compare May 8, 2023 17:02
@howardjohn
Copy link
Member Author

/test all

@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from a99f3fb to 4feac7f Compare May 8, 2023 19:11
@howardjohn
Copy link
Member Author

/test all

@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from 4feac7f to 6a45fa4 Compare May 8, 2023 19:34
@howardjohn howardjohn marked this pull request as ready for review May 8, 2023 20:31
howardjohn added a commit to howardjohn/istio that referenced this pull request May 19, 2023
@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch 3 times, most recently from 87ed219 to efb8bbe Compare May 19, 2023 18:11
istio-testing pushed a commit that referenced this pull request May 22, 2023
@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch 4 times, most recently from 23b9883 to d924f75 Compare May 22, 2023 19:46
// already started, ignore
default:
c.stop = stop
close(c.running)
Copy link
Member

Choose a reason for hiding this comment

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

This is not concurrent safe, will panic if called concurrently

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, added a mutex

}
inf.Start(stop)
// Swap out the dummy client with the full one
delayedClient.set(fc)
Copy link
Member

Choose a reason for hiding this comment

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

We need a log here

@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from 0317fdd to f07931a Compare May 23, 2023 14:43
@howardjohn howardjohn removed the do-not-merge/hold Block automatic merging of a PR. label May 23, 2023
* Remove syncronous List; it is duplicated with the informer
* Refactoring ordering a bit
* use kclient which ensures handler is called once we check HasSynced
@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from f07931a to 4793472 Compare May 23, 2023 17:37
@istio-testing
Copy link
Collaborator

istio-testing commented May 23, 2023

@howardjohn: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
bookinfo-build_istio cf1d3803a857e57e8048786810432bbf9eaf4ee5 link true /test bookinfo-build

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@howardjohn howardjohn force-pushed the kube/cleanup-crdwatcher branch from 4793472 to e6ac82c Compare May 23, 2023 21:16
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants