-
Notifications
You must be signed in to change notification settings - Fork 398
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
✨ Switch to cluster-aware k8s clients, listers & informers #2104
✨ Switch to cluster-aware k8s clients, listers & informers #2104
Conversation
dc388b5
to
9a09395
Compare
502785a
to
a54c7a1
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
dfbd0ff
to
73d7d54
Compare
} | ||
|
||
source = c.factory(cluster) | ||
c.sources[cluster] = source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this map ever being cleaned up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not - seems like a good follow-up. We need the rebase to 1.25 to get resource event handler function cleanup on the (shared, cross-cluster) list.
73d7d54
to
504302c
Compare
504302c
to
3908bfc
Compare
|
|
||
func (c *crdClusterLister) Cluster(name logicalcluster.Name) kcp.ClusterAwareCRDLister { | ||
if name != bootstrap.SystemCRDLogicalCluster { | ||
klog.Background().Error(fmt.Errorf("cluster-unaware crd lister got asked for %v cluster", name), "programmer error") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm ... good question - it must have come from somewhere previous. Do you know? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's only ever valid to use this particular cluster - maybe we don't need a Cluster()
call here at all, let me remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see - when it's the APIBinding-aware one, this does not apply. I am just carrying forward the previous impl IUIC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and it was your first-pass impl that hard-coded this value, and has a TODO for future improvements ;) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd like to see how the apiextention server will be using crdClusterLister
, could you please provide me with a link to your fork?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, clarified with Steve in a gmeet.
|
Makefile
Outdated
@@ -208,6 +208,9 @@ GO_TEST = $(GOTESTSUM) $(GOTESTSUM_ARGS) -- | |||
endif | |||
|
|||
COUNT ?= 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if instead we defaulted to unset, and if it's not empty, then set TEST_COUNT? Otherwise, you can't specify COUNT=1 and have it force running a test w/o hitting the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK - can drop this commit & do it stand-alone
@@ -189,30 +189,30 @@ require ( | |||
|
|||
replace ( | |||
github.com/kcp-dev/kcp/pkg/apis => ./pkg/apis | |||
k8s.io/api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20221005071841-6cfb7d485cbf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you'll drop/replace this commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the last commit & will be replaced with the fork once we merge the k8s PR
Almost forgot ... TODO:
Daniel Smith suggested not implementing delete collection in the fake, said it was not well supported in k8s as it were ... can we get away with not using that verb? |
@@ -112,7 +112,7 @@ func (c *controller) reconcile(ctx context.Context, apiBinding *apisv1alpha1.API | |||
} | |||
|
|||
claimLogger.V(4).Info("listing resources") | |||
objs, err := informer.Informer().GetIndexer().ByIndex(indexers.ByLogicalCluster, clusterName.String()) | |||
objs, err := informer.Lister().ByCluster(clusterName).List(labels.Everything()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where can I check the new interface of a lister?
what is ByCluster
? an index?
how does it differ from configMapInformer.Lister().Cluster(cluster).ConfigMaps(namespace).Get(name)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was following the pattern of dynamic/generic listers doing ByNamespace()
- but perhaps we should not do that and make it .Cluster()
? You can see the implementation used in this PR already published to kcp-dev/client-go
- https://github.com/kcp-dev/client-go/blob/272de79b2a7ab1d29e7d0db2d458258d035124d4/clients/metadata/metadatalister/shim.go#L54-L56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I'd prefer to have Cluster()
method on the dynamic client
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
We turned off the controller upstream, so we can stop serving the types entirely. Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
61cfd4c
to
fd306c5
Compare
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
fd306c5
to
c948a85
Compare
No description provided.