-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
PoC: Create an Api::dynamic
and Api::cluster
+ scope constrain Api::all
#1313
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1313 +/- ##
=======================================
- Coverage 72.4% 72.4% -0.0%
=======================================
Files 75 75
Lines 6343 6357 +14
=======================================
+ Hits 4587 4597 +10
- Misses 1756 1760 +4
|
Signed-off-by: clux <[email protected]>
I think there isn't much gain in limiting all to It would be different if we would also track as a second generic how the |
While I am not attached to this particular design, I think it's important to keep in mind that this code setup might not help Sure, the generic code case was never easy, but I don't think a setup like this would make it significantly harder - particularly if they have written all the cases you linked. It's also a minority of people that needs to write that code. It's generic code. The number of people encountering the pain needs to be considered. As a side-note, I almost feel like those particular generic api getters are done at the wrong level. That code is setup to expose an interface for a namespace on something that doesn't have a namespace. This means you no longer know by type whether it's safe to unwrap the To illustrate some ways you can do generics (because I ended up thinking about this a bit this week), there's a new PR at kube-rs/website#47 to show some ways to get around some of these issues in easier ways. |
As an extra point, I do think there are two orthogonal use-cases for
It is possible we need to follow a style a bit more like client-go and have a ListWatcher style entrypoint for watcher. |
Proof of Concept
Wanted to see how this ended up looking. I am not 100% convinced about this yet.
Motivation
Currently the biggest footgun in kube right now is
Api::all
and its interaction with Namespaced objects.An
Api::all
on aResource = NamespacedResource
is an extremely stunted implementation that only really allowsApi::list
,Api::watch
.All the other Api methods will fail with 404s because it by construction creates invalid request urls.
Main issues:
get
withApi::all()
response can't be 404 #1276Api::all
fails to create namespaced resources #1030and a couple from discussions:
finalizer
Proposal
Api::all
Api::all
unless they actually want a cross-namespace listerThis does mean one breaking change:
Api::all
now requiresNamespaceResourceScope
+ put a big warning on it that it's only for listwatching.and add two new main
Api
constructors to compensate:Api::cluster
- limited toClusterResourceScope
Api::dynamic
- limited toDynamicResourceScope
a potential setup for api construction from discovery to show this does not make it worse
Alternatives
NamespaceResourceScope
scope constraint onApi::all
for a non-breaking change.Api
no matter what, so thought we may as well make this as good as possibleDrawbacks