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

support partition consumer mode for kafka channel #879

Merged
merged 4 commits into from
Mar 14, 2019

Conversation

yuzisun
Copy link
Contributor

@yuzisun yuzisun commented Mar 9, 2019

Fixes #693

Proposed Changes

  • support partition consumer mode which allows dispatching events from different partitions in parallel instead of a single go channel.
  • added consumer_mode in kafka channel config, by default it is still doing multiplexing. When consumer_mode is set to partitions, kafka dispatcher should start creating partition consumer for the channels and events are dispatched on different go channels for different partitions.

Release Note

Added `consumer_mode` config option in config map `kafka-channel-controller-config`, default value is `multiplex` which retains existing behavior, if you set `consumer_mode` to be `partitions`,  it creates a go channel per partition for the consumer when dispatching the events to your service.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 9, 2019
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 9, 2019
Copy link
Contributor

@Harwayne Harwayne left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@Harwayne
Copy link
Contributor

Harwayne commented Mar 9, 2019

/ok-to-test

@knative-prow-robot knative-prow-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 9, 2019
Copy link
Contributor

@n3wscott n3wscott left a comment

Choose a reason for hiding this comment

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

nice bit of work!

contrib/kafka/main.go Outdated Show resolved Hide resolved
contrib/kafka/pkg/controller/util.go Show resolved Hide resolved
contrib/kafka/pkg/dispatcher/dispatcher.go Show resolved Hide resolved
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
contrib/kafka/pkg/dispatcher/dispatcher.go 71.1% 69.9% -1.2

@matzew
Copy link
Member

matzew commented Mar 13, 2019

/lgtm

nice idea.

Perhaps we should change this to be the default behavior, in the future

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 13, 2019
} else {
break
if cluster.ConsumerModePartitions == d.kafkaCluster.GetConsumerMode() {
go d.partitionConsumerLoop(consumer, channelRef, sub)
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks a lot, this looks easier to test now.

@n3wscott
Copy link
Contributor

/lgtm

Copy link
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

@yuzisun Thanks, and thanks for writing unit tests! Did you verify this feature works in a real cluster? I'm not very familiar with the Kafka channel and there aren't any E2E tests yet, so I'd like to hear from at least one person who's seen this code work in real life 😀

Also, since this adds a feature to the Kafka channel config map, can you write a blurb about it in the Release Note block? Seems like it can be copied from your Proposed Changes list.

istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/runtime"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"os"
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you run gofmt on this file? I'd have expected it to put this import above next to flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm I did run gofmt -w main.go, nothing changes, then I purposely put next to flag and rerun gofmt it puts os back after _ k8s.io/client-go/plugin/pkg/client/auth/gcp, looks weird. I am using go version go1.11.5 darwin/amd64

Copy link
Contributor

Choose a reason for hiding this comment

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

weird! I don't know why it does that, but I guess it's correct by definition. So 👍

@yuzisun
Copy link
Contributor Author

yuzisun commented Mar 13, 2019

@yuzisun Thanks, and thanks for writing unit tests! Did you verify this feature works in a real cluster? I'm not very familiar with the Kafka channel and there aren't any E2E tests yet, so I'd like to hear from at least one person who's seen this code work in real life 😀

Also, since this adds a feature to the Kafka channel config map, can you write a blurb about it in the Release Note block? Seems like it can be copied from your Proposed Changes list.

Added the release note. I did verify this in the real cluster and I can also look into adding a E2E test for kafka.

Copy link
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Added the release note. I did verify this in the real cluster and I can also look into adding a E2E test for kafka.

Thanks! I took the liberty of moving the release note text into the ```releasenote block. E2E tests can be another PR.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, yuzisun

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:

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 13, 2019
@yuzisun
Copy link
Contributor Author

yuzisun commented Mar 14, 2019

/retest

@knative-prow-robot knative-prow-robot merged commit b7738a4 into knative:master Mar 14, 2019
Harwayne pushed a commit to Harwayne/knative-eventing that referenced this pull request Mar 14, 2019
* support partition consumer for kafka channel

* consolidate GetProvisionerConfig function

* add consumer mode config test

* address review comments
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants