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

✨ Use watchList in typed and unstructured client if WatchListClient is enabled #3136

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Mar 2, 2025

Signed-off-by: Stefan Büringer [email protected]

Fixes #3055

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 requested review from FillZpp and troy0820 March 2, 2025 13:57
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 2, 2025
@sbueringer
Copy link
Member Author

/hold
First commit is from #3135

Otherwise ready for review

@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 Mar 2, 2025
@@ -2199,1464 +2205,1759 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
})
})

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to move the List tests out, but with a bit of creative diff'ing it should be okay'ish to review

})

// TODO(seans): get label selector test working
It("should filter results by label selector", func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this test as it was not implemented for unstructured before

Copy link
Member

Choose a reason for hiding this comment

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

Can the TODO go then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. Copied this from another case and forgot to look up why the TODO was there. Apparently when the TODO was added the test was commented out. Dropped the TODOs

deleteNamespace(ctx, clientset, tns4)
})

It("should filter results using limit and continue options", func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this test as it was not implemented for unstructured before


It("should fetch unstructured collection of objects, even if scheme is empty", func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to the unstructured section


It("should fetch unstructured collection of objects", func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was redundant with the one in the unstructured section, so I deleted it

@sbueringer
Copy link
Member Author

/assign @alvaroaleman @vincepri

@sbueringer
Copy link
Member Author

/hold cancel

Rebased on top of main, now that #3135 is merged

@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 Mar 2, 2025
@sbueringer
Copy link
Member Author

sbueringer commented Mar 2, 2025

/cc @p0lyn0mial @sttts (just fyi)

@k8s-ci-robot k8s-ci-robot requested a review from sttts March 2, 2025 16:04
@k8s-ci-robot
Copy link
Contributor

@sbueringer: GitHub didn't allow me to request PR reviews from the following users: p0lyn0mial.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @p0lyn0mial @sttts

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-sigs/prow repository.

if err == nil {
return nil
}
log.FromContext(ctx).Error(err, fmt.Sprintf("Warning: The watchlist request for %s ended with an error, falling back to the standard LIST semantics", r.resource()))
Copy link
Member

Choose a reason for hiding this comment

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

If I understand it correctly, this failing is expected if the KAS is too old, right? If yes, then this i IMHO a debug log. The other log re preparing watchlist opts however seems like an actual error log because that is never expected to happen or am I missunderstanding things?

Copy link
Member Author

@sbueringer sbueringer Mar 3, 2025

Choose a reason for hiding this comment

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

Took another look.

The other log re preparing watchlist opts however seems like an actual error log because that is never expected to happen

I agree. PrepareWatchListOptionsFromListOptions only returns an error if scheme.Convert fails.

this failing is expected if the KAS is too old, right? If yes, then this i IMHO a debug log.

This error will happen whenever the WatchList feature is disabled in KAS (either because KAS is too old to have the feature or because it's explicitly disabled).

I personally would never enable the WatchListClient client-side feature gate if I"m not 100% sure that I'm communicating with a v1.32 apiserver. The reason for that is that the fallback behavior means that every single List call will fail with a WatchList first. That's pretty disastrous if it happens in my opinion, so I thought it's good if in these cases the log message shows up so they can fix their config (basically it surfaces a client-side configuration error).

Copy link
Member

Choose a reason for hiding this comment

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

I personally would never enable the WatchListClient client-side feature gate if I"m not 100% sure that I'm communicating with a v1.32 apiserver

Right but this will be enabled by default in 1.33 client-go or not? So its not something people will be aware of.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right but this will be enabled by default in 1.33 client-go or not? So its not something people will be aware of.

Hm no idea when it will be enabled per default, it's currently not enabled per default in k/k main: https://github.com/kubernetes/kubernetes/blob/a9aab298b4738f4ea9111131cdf193a3b1ba14e5/staging/src/k8s.io/client-go/features/known_features.go#L83

But that's actually a good point. As soon as this is enabled per default, folks will hit these failure cases if they hit an apiserver which is too old which is not great (I think the log message is the smallest problem here :))

@p0lyn0mial I couldn't find a tracking issue for WatchListClient. What are the current plans regarding enabling this per default? Or is the idea to keep it of for the forseeable future to avoid that folks are implicitly hitting these error cases with old apiservers simply by bumping client-go?

Copy link
Member Author

Choose a reason for hiding this comment

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

Found the tracking issue: kubernetes/enhancements#3157 Still not sure about when WatchListClient would be enabled per default though :)

Choose a reason for hiding this comment

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

The plan is to enable the feature (WatchListClient) by default on 1.34 (next release). The issue is quite outdated :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I think that means a lot of folks will have to expliclity set the feature gate to false starting with client-go v1.34 to not run into problems.

})

// TODO(seans): get label selector test working
It("should filter results by label selector", func() {
Copy link
Member

Choose a reason for hiding this comment

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

Can the TODO go then?

@sbueringer
Copy link
Member Author

/hold
Until we have consensus if and how we want to support watchlist in our live clients.

@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 Mar 7, 2025
@caozhuozi
Copy link

is it possible we can have a one-shot global check for whether we have WATCH permission at the controller-runtime start?

@sbueringer
Copy link
Member Author

sbueringer commented Mar 8, 2025

is it possible we can have a one-shot global check for whether we have WATCH permission at the controller-runtime start?

In general roughly yes, although I would implement it differently. But we're going to wait to see what will be done in client-go: https://kubernetes.slack.com/archives/C0EG7JC6T/p1741283769908819?thread_ts=1741283769.908819&cid=C0EG7JC6T

@sbueringer
Copy link
Member Author

sbueringer commented Mar 8, 2025

(just rebased onto main & added a commit to ensure all unstructured & partialobjectmeta tests use a client with an empty scheme)

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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure APIStreaming is used if available
6 participants