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

HACK: Search for the right CRD cluster when watching with wildcards #15

Merged

Conversation

davidfestal
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

Before this PR one could not watch with wildcards (across logical clusters) if the CRD of the related API Resource hadn't been added in the admin logical cluster first.

Now when watching or listing with wildcards on a resource driven by a CRD, we search for the right logical cluster hosting the given CRD.

Which issue(s) this PR fixes:

Fixes kcp-dev/kcp#183

Special notes for your reviewer:

The fix in this Kube HACK is limited since the request will fail if 2 logical clusters
contain CRDs for the same GVK with non-equal specs (especially non-equal schemas).
The complete implementation would come when implementation directions for API Definition management in KCP are clearly defined.

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

This hack fixes issue kcp-dev/kcp#183: One cannot
watch with wildcards (across logical clusters) if the CRD of the related API Resource
hasn't been added in the admin logical cluster first.

The fix in this HACK is limited since the request will fail if 2 logical clusters
contain CRDs for the same GVK with non-equal specs (especially non-equal schemas).

Signed-off-by: David Festal <dfestal@redhat.com>
crds, err = r.crdLister.List(labels.Everything())
if err == nil {
if len(crds) == 0 {
err = errors.NewNotFound(schema.GroupResource{Group: apiextensionsv1.SchemeGroupVersion.Group, Resource: "customresourcedefinitions"}, "")
Copy link
Member

Choose a reason for hiding this comment

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

would expect an empty set rather than a NotFound.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it seems to me that returning an empty set would mainly mean: this API exists but there is not resource of this API.
The situation here is that the API itself is unknown (no CRD is available), which afaict is reflected by a NotFound error.
But I realize that I should also trigger a NotFound error when no CRD was found after iterating the CRD list.

Copy link
Member

Choose a reason for hiding this comment

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

sounds reasonable. The proxy will ignore NotFound if there is another shard that has the CRD.

crd = aCRD
crdClusterName = aCRD.GetClusterName()
} else {
if !equality.Semantic.DeepEqual(crd.Spec, aCRD.Spec) {
Copy link
Member

Choose a reason for hiding this comment

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

I see why you say it is a temporary hack :)

@stevekuznetsov stevekuznetsov merged commit 3316bdf into kcp-dev:feature-logical-clusters-1.22 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants