Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

kafka-ch-dispatcher has no ownerref #1188

Closed
AceHack opened this issue May 2, 2020 · 23 comments · Fixed by #1536
Closed

kafka-ch-dispatcher has no ownerref #1188

AceHack opened this issue May 2, 2020 · 23 comments · Fixed by #1536
Assignees
Labels
channel/kafka Kafka channel related issue kind/bug Categorizes issue or PR as related to a bug.

Comments

@AceHack
Copy link
Contributor

AceHack commented May 2, 2020

Describe the bug
kafka-ch-dispatcher gets created as needed but without a ownerref, this causes problems on uninstall of eventing as the kafka-ch-dispatcher deployment never gets cleaned up and is left around as an orphan crash loop forever.

Expected behavior
kafka-ch-dispatcher to get cleaned up on uninstall of knative Kafka channel controller.

To Reproduce
Install knative Kafka channel controller
Create a kafka channel
Delete a Kafka channel
Uninstall knative Kafka channel controller

Knative release version
0.14.1

Related issue
knative/eventing#3035

@AceHack AceHack added the kind/bug Categorizes issue or PR as related to a bug. label May 2, 2020
@AceHack AceHack changed the title kafka-ch-dispatcher has not ownerref kafka-ch-dispatcher has no ownerref May 2, 2020
@grantr grantr added the channel/kafka Kafka channel related issue label May 4, 2020
@aliok
Copy link
Member

aliok commented Sep 2, 2020

/assign

@aliok
Copy link
Member

aliok commented Sep 7, 2020

This will be only solved for the cluster scoped dispatcher.

The namespaced dispatcher won't still have an "OwnerRef" because the strategy here is to create the dispatcher in advance with an ownerRef. The namespace dispatchers need to be created later and we there's nothing that can be set as the ownerRef. If it was per channel, instead of per namespace, we would be able to set the CR instance as the owner.

Related: #1524

@aliok
Copy link
Member

aliok commented Sep 8, 2020

Oh boy... Can't create the dispatcher service in advance... The thing is, the type should be set to ExternalName but that requires the externalName to be set to. And in the code, we set it to fmt.Sprintf("%s.%s.svc.%s", dispatcherName, testNS, utils.GetClusterDomainName()) which cannot be done in the YAML.

Another approach would be creating the service in advance with another type and then change it in the reconciliation. But, once the service is set up like that, we cannot update the service.

@lionelvillard @slinkydeveloper @vaikas any suggestions?

BTW, there are 2 kinds of dispatchers:

  1. Cluster scoped dispatchers
  2. Namepaced dispatchers

This I was only attempting to fix the 1st one's ownerRef by setting it to the KnativeEventing CR in the operator.
For the 2nd one, there's nothing available as the ownerRef. Instead of dispatcher per namespace, we can actually do dispatcher per channel CR, which would allow us to set the channel CR as the ownerRef.

I need feedback.

@matzew
Copy link
Member

matzew commented Sep 8, 2020

sounds messy... 🤔

@slinkydeveloper
Copy link
Contributor

slinkydeveloper commented Sep 8, 2020

Ok maybe it's me, but i didn't properly get what's the problem here. @aliok the dispatcher is brought up by the controller right? In both cases, could the owner ref be just the controller deployment?

@aliok
Copy link
Member

aliok commented Sep 8, 2020

Don't know. Could work I guess. Let me think about that.

@lionelvillard
Copy link
Member

we tried setting the owner ref to be the controller using the downward API without success (problem with the uid if I recall well).

@aliok
Copy link
Member

aliok commented Sep 9, 2020

For reference:
These 2 comments explain why the controller can't be used as the owner:

Can't come up with any alternatives to set as the owner.

@aliok
Copy link
Member

aliok commented Sep 9, 2020

Oh boy... Can't create the dispatcher service in advance... The thing is, the type should be set to ExternalName but that requires the externalName to be set to. And in the code, we set it to fmt.Sprintf("%s.%s.svc.%s", dispatcherName, testNS, utils.GetClusterDomainName()) which cannot be done in the YAML.

My bad... I don't think this is accurate: externalName is not needed.
Reworking a PR now.

@aliok
Copy link
Member

aliok commented Sep 9, 2020

Reworked PR: #1536

@vaikas
Copy link
Contributor

vaikas commented Sep 9, 2020

For the namespaced one, using the ownerref of the channel seems reasonable to me. The only caveat is that do we really want there to be 1:1 mapping between a channel and a dispatcher?
For the cluster one, if it's the problem getting the UID, can't we just ask the API server who am I and get the UID?

@aliok
Copy link
Member

aliok commented Sep 9, 2020

For the namespaced one, using the ownerref of the channel seems reasonable to me. The only caveat is that do we really want there to be 1:1 mapping between a channel and a dispatcher?

Won't work if there's more than 1 channel in a namespace.

For the cluster one, if it's the problem getting the UID, can't we just ask the API server who am I and get the UID?

I think this will be fine now, with the PR: #1536

@AceHack
Copy link
Contributor Author

AceHack commented Sep 11, 2020

We have more than one channel per namespace. Will this fix my issue?

@lionelvillard
Copy link
Member

@AceHack Are you using the hidden eventing.knative.dev/scope annotation?

@AceHack
Copy link
Contributor Author

AceHack commented Sep 11, 2020

I didn't think it was hidden, it's called out here in the docs.
https://github.com/knative/eventing-contrib/tree/master/kafka/channel#namespace-dispatchers

And yes we are using that

@lionelvillard
Copy link
Member

thanks @AceHack. Can I ask you a couple more questions:

  • Are you also using the cluster dispatcher?
  • If the answer is no, would you be ok if instead of the annotation we provide a release artifact that only includes the namespace dispatcher?

thanks.

@AceHack
Copy link
Contributor Author

AceHack commented Sep 11, 2020

Currently, we are also using the cluster dispatcher but we could avoid it, it's not absolutely necessary. It's some more works for us to deploy the namespace dispatcher separately but something we could do.

@AceHack
Copy link
Contributor Author

AceHack commented Sep 11, 2020

We have multiple kafka clusters and need the ability to connect to the different ones per namespace

@lionelvillard
Copy link
Member

thanks @AceHack, this is very helpful!

@AceHack
Copy link
Contributor Author

AceHack commented Sep 11, 2020

We actually would like to connect to different ones per topic, but we've been getting by with per namespace.

@lionelvillard
Copy link
Member

@aliok
Copy link
Member

aliok commented Sep 14, 2020

@AceHack

We have more than one channel per namespace. Will this fix my issue?

No, in the fix PR, only the cluster scope dispatcher is created in advance.

For the namespaced ones nothing changed.

@aliok
Copy link
Member

aliok commented Sep 14, 2020

We actually would like to connect to different ones per topic, but we've been getting by with per namespace.

IMO we should have all these information in the CR: cluster, topic, etc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
channel/kafka Kafka channel related issue kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants