components-contrib icon indicating copy to clipboard operation
components-contrib copied to clipboard

Kafka's clientID to default to appID

Open artursouza opened this issue 2 years ago • 14 comments

Today, Kafka's pubsub and binding default clientID to sarama - which is useless. Since clientID is used by Kafka to apply quotas and set in tracing, defaulting to Dapr's appID make more sense.

https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-apache-kafka/#spec-metadata-fields

Related to: https://github.com/dapr/dapr/issues/5690

artursouza avatar Dec 31 '22 01:12 artursouza

@artursouza would it make sense to default it to {namespace}? This translates to $"{namespace}.{appID}". Is appID enforced to be unique over namespaces? If not, {namespace} seems to be the most precise, human-readable identifier. Aside, namespace is quite an unlucky name for the template string, as it's more than that, too late to change something as trivial as this?

VerstraeteBert avatar Jan 12 '23 21:01 VerstraeteBert

appID is not enforced to be unique across namespaces. however, when running in self-hosted mode (outside of K8s), Dapr by default does not have a namespace configured.

yaron2 avatar Jan 12 '23 21:01 yaron2

Thanks for the explanation. Makes sense to me to have {appId} as the clientId in self-hosted mode and {namespace} in k8s 👍 . I'll get on it during the weekend.

VerstraeteBert avatar Jan 12 '23 21:01 VerstraeteBert

Thanks for the explanation. Makes sense to me to have {appId} as the clientId in self-hosted mode and {namespace} in k8s 👍 . I'll get on it during the weekend.

@artursouza does this seem reasonable to you? looks fine to me.

yaron2 avatar Jan 12 '23 22:01 yaron2

LGTM

artursouza avatar Jan 12 '23 22:01 artursouza

@artursouza would it make sense to default it to {namespace}? This translates to $"{namespace}.{appID}". Is appID enforced to be unique over namespaces? If not, {namespace} seems to be the most precise, human-readable identifier. Aside, namespace is quite an unlucky name for the template string, as it's more than that, too late to change something as trivial as this?

I am not a fan of {namespace} implementation either. I think we should have a deprecation notice to that and change the implementation to be just the actual namespace - although it is not portable when running outside K8s.

artursouza avatar Jan 12 '23 22:01 artursouza

After this change is in. I propose we simply make a breaking change where {namespace} means the actual namespace only and existing users should use {appId} concatenated going forward to keep existing behavior.

artursouza avatar Jan 12 '23 22:01 artursouza

App ID and namespace aren't available in contrib right now.

Can this be added to the context object we use everywhere?

Or alternatively runtime can inject this as specially prefixed metadata (properties) keys which then can be access in every component!

Not sure how I feel about a component making an extra API call to retrieve the app ID and namespace - I'm personally against this because it also introduces new failure scenarios.

berndverst avatar Jan 12 '23 22:01 berndverst

Some of the discussion here is about https://github.com/dapr/dapr/issues/5690 - for contrib, as long as more context is passed to components (like consumerID), then each component can use those for "better" default value in some properties.

artursouza avatar Jan 12 '23 23:01 artursouza

Yes to set the better defaults in the component the app ID and namespace need to be accessible. That can only be done by injecting them into the metadata properties map within runtime. Each component's Init message has access to these.

berndverst avatar Jan 12 '23 23:01 berndverst

@berndverst @artursouza thanks for the discussion and pointers. Will delve deeper into the code soon.

VerstraeteBert avatar Jan 18 '23 20:01 VerstraeteBert

I will look into this to validate the latest state of Kafka.

artursouza avatar Jun 30 '23 17:06 artursouza

Validated, but waiting on docs PR ^ to be merged before closing this issue

cicoyle avatar Sep 08 '23 19:09 cicoyle

/assign

cicoyle avatar Sep 11 '23 18:09 cicoyle