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

KafkaSink CRD, types and reconciler #134

Merged
merged 24 commits into from Sep 10, 2020

Conversation

pierDipi
Copy link
Member

@pierDipi pierDipi commented Aug 31, 2020

We can reuse the same receiver component of the data plane to build a KafkaSink.

Proposed Changes

  • Add KafkaSink CRD, types and reconciler

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 31, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 31, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 31, 2020
@slinkydeveloper
Copy link
Contributor

slinkydeveloper commented Aug 31, 2020

So this PR still doesn't contain the KafkaSink controller right? Can you implement the controller in this PR (or even a separate one which depends on this one), i wonder how big the code is 😄

@pierDipi
Copy link
Member Author

@slinkydeveloper I would like to consolidate the CRD in this one and then in a separate PR implement the reconciler. WDYT?

@pierDipi
Copy link
Member Author

It will probably be roughly 3k+ LOC (validation, types, and reconciler + tests)

@slinkydeveloper
Copy link
Contributor

@slinkydeveloper I would like to consolidate the CRD in this one and then in a separate PR implement the reconciler. WDYT?

I'm ok with that, but I think you should start implementing the controller now and keep the 2 PRs separate, this should simplify the feedback on this PR too

- numPartitions
- replicationFactor
- bootstrapServers
properties:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need an optional "encoding" flag here, to let the user choose between structured and binary. Also, i think the default should be structured (it's quite unnatural in kafka world to send stuff in headers, so i think kafka users would prefer the structured mode as default)

Copy link
Member Author

@pierDipi pierDipi Aug 31, 2020

Choose a reason for hiding this comment

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

CE spec calls them message mode: https://github.com/cloudevents/spec/blob/master/spec.md#message, do you think encoding is more descriptive?

Copy link
Contributor

Choose a reason for hiding this comment

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

To me, on this context, mode seems too "broad"... But i would love to hear people other people opinions @matzew

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Or contentMode

Copy link
Member Author

Choose a reason for hiding this comment

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

@slinkydeveloper Is it ok for you if we use contentMode?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not aware of any discussions around a Sink duck type but I'm sure @n3wscott has some ideas. As you said it must be addressable, and it should includes ceOverrides, contentMode and possibly dataContentType (For RedisStreamSink data can either be json-encoded or RESP-encoded). Anyway do you mind opening an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

As yesterday discussion during eventing sources wg, I think for now we should proceed forward to shape this KafkaSink CRD as an Addressable and nothing else, since my understanding is that this is the only need for a Sink.
If at some point, we need to abstract something more than Addressable for a sink, we can create that sink duck type and bump this KafkaSink CRD. This process should also help us to better understand what we need to abstract, other than Addressable itself.
WDYT @n3wscott @lionelvillard @pierDipi ?

Copy link

Choose a reason for hiding this comment

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

I would not call it a Sink. The concept is a sink, just like a source is a source in concept. Call it what it is for Kafka is my recommendation, but I have had a lot of pushback on this idea. Folks just want to add the label to everything....

A kafka source would be KafkaSubscription
A kafka sink would be a KafkaTopic

A kafka channel would make n KafkaSubscription for the controlled KafkaTopic

@pierDipi
Copy link
Member Author

I'm ok with that, but I think you should start implementing the controller now and keep the 2 PRs separate, this should simplify the feedback on this PR too

Sure

@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 31, 2020
@pierDipi
Copy link
Member Author

pierDipi commented Aug 31, 2020

Added types (and code generation): b671be1

@pierDipi pierDipi force-pushed the kafka-sink branch 4 times, most recently from d88230b to 835de79 Compare September 1, 2020 10:57
Copy link
Contributor

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v .pb.go | grep -v wire_gen.go)

@pierDipi
Copy link
Member Author

pierDipi commented Sep 1, 2020

Maven...
/retest

@pierDipi
Copy link
Member Author

pierDipi commented Sep 1, 2020

/lint

Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@pierDipi: 34 warnings.

In response to this:

/lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

control-plane/pkg/reconciler/sink/kafka_sink.go Outdated Show resolved Hide resolved
control-plane/pkg/reconciler/base/broker/broker_base.go Outdated Show resolved Hide resolved
control-plane/pkg/apis/eventing/register.go Outdated Show resolved Hide resolved
control-plane/pkg/apis/eventing/register.go Show resolved Hide resolved
control-plane/pkg/reconciler/broker/topic.go Outdated Show resolved Hide resolved
control-plane/pkg/reconciler/trigger/controller.go Outdated Show resolved Hide resolved
control-plane/pkg/reconciler/broker/broker.go Outdated Show resolved Hide resolved
@pierDipi
Copy link
Member Author

pierDipi commented Sep 9, 2020

Rebased.

@knative-metrics-robot
Copy link

@slinkydeveloper
Copy link
Contributor

Are you ok with that?

@pierDipi I think the control plane is fine as is, let's avoid creating too much controller images

@pierDipi
Copy link
Member Author

pierDipi commented Sep 9, 2020

@pierDipi I think the control plane is fine as is, let's avoid creating too much controller images

Just to clarify, I meant to create another YAML, eg

  1. control plane (eventing-kafka-control-plane.yaml) - required
  2. sink data plane (eventing-kafka-sink.yaml)
  3. broker data plane (eventing-kafka-broker.yaml)

Users choose 2 or 3 or both.

Images remain 3 (but we package one per YAML).

@slinkydeveloper
Copy link
Contributor

Ah ok so we keep the control plane all together but we split the data plane deployments, one yaml for sink and one for broker. What happens if i install the control plane but only one of the two data planes?

@pierDipi
Copy link
Member Author

pierDipi commented Sep 9, 2020

As it is now you can create a Broker or a KafkaSink but there won't be a data plane for it, so it'll get ready but it isn't actually ready since there is not data plane, we can add a check to see if it exists or not and reflect that in the status.

I would do this in a different PR once this is in.


if err := envconfig.Process("", &brokerEnvConfigs); err != nil {
log.Fatal("cannot process environment variables", err)
brokerEnv, err := config.GetEnvConfig("BROKER")
Copy link

Choose a reason for hiding this comment

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

We should prefix special knative things with K_

Copy link

Choose a reason for hiding this comment

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

I am not sure it is a good idea to call envconfig.Process on each get accessor.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean by special?

I see those configurations just like SYSTEM_NAMESPACE (which is part of them) which hasn't a K_ prefix. 😕

I am not sure it is a good idea to call envconfig.Process on each get accessor.

How do you set the same set of configurations with different prefixes without duplicating the struct? We have the same set of configurations for two reconcilers with different values, BROKER and SINK are prefixes to distinguish the two: https://github.com/knative-sandbox/eventing-kafka-broker/pull/134/files#diff-2e77fe22a128ec539d95f2e10c96eff6R60-R88,


var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{

eventingv1alpha1.SchemeGroupVersion.WithKind("KafkaSink"): &eventingv1alpha1.KafkaSink{},
Copy link

Choose a reason for hiding this comment

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

I would not call it a Sink. The concept is a sink, just like a source is a source in concept. Call it what it is for Kafka is my recommendation, but I have had a lot of pushback on this idea. Folks just want to add the label to everything....

A kafka source would be KafkaSubscription
A kafka sink would be a KafkaTopic

A kafka channel would make n KafkaSubscription for the controlled KafkaTopic

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose the reason why we have the KafkaSource is to keep the naming consistent with the eventing concept event source, similarly to why we should name this KafkaSink to align with the eventing concept of event sink

- numPartitions
- replicationFactor
- bootstrapServers
properties:
Copy link

Choose a reason for hiding this comment

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

I would not call it a Sink. The concept is a sink, just like a source is a source in concept. Call it what it is for Kafka is my recommendation, but I have had a lot of pushback on this idea. Folks just want to add the label to everything....

A kafka source would be KafkaSubscription
A kafka sink would be a KafkaTopic

A kafka channel would make n KafkaSubscription for the controlled KafkaTopic

@matzew
Copy link
Contributor

matzew commented Sep 9, 2020

I really like this. see a little doc on usage:

https://gist.github.com/matzew/e2c2fcd2696a346f25b8bc9e64bfd0fa

@slinkydeveloper
Copy link
Contributor

@matzew cool! We can use your doc as a starting point for the docs pr

@n3wscott
Copy link

n3wscott commented Sep 9, 2020

I will relent. Symmetry with the poorly named KakfaSource means KakfaSink 😢

Copy link
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

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

Green flag for me!
/approve
/lgtm
/hold I'm gonna wait for another review

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2020
@knative-prow-robot knative-prow-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 10, 2020
Copy link
Contributor

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, pierDipi, slinkydeveloper

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [matzew,slinkydeveloper]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@matzew
Copy link
Contributor

matzew commented Sep 10, 2020

I think the name does match the current "design" - and yes, naming is hard ...

@slinkydeveloper
Copy link
Contributor

Who's gonna unhold this? 😄

@slinkydeveloper
Copy link
Contributor

/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2020
@knative-prow-robot knative-prow-robot merged commit d37cf4a into knative-extensions:master Sep 10, 2020
@pierDipi pierDipi mentioned this pull request Oct 1, 2020
@pierDipi pierDipi deleted the kafka-sink branch April 14, 2021 21:18
matzew pushed a commit to matzew/eventing-kafka-broker that referenced this pull request Mar 17, 2022
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>

Co-authored-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants