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

Refactored Kafka src and ch code to reuse same consumer group handler code #554

Conversation

slinkydeveloper
Copy link
Contributor

@slinkydeveloper slinkydeveloper commented Aug 22, 2019

Replaces #551
Fixes knative/eventing#944
Fixes #552

Proposed Changes

  • Removed sarama-cluster lib
  • Refactored Kafka channel and source to share same code for handling incoming kafka messages
  • Now kafka source commit the offset when the message is malformed

Release Note

consumerMode property in kafka broker config-map is no longer supported
sarama now uses v2 apis

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

Hi @slinkydeveloper. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@matzew
Copy link
Member

matzew commented Aug 22, 2019

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 22, 2019
@matzew
Copy link
Member

matzew commented Aug 23, 2019

/retest

@matzew
Copy link
Member

matzew commented Aug 23, 2019

@slinkydeveloper

to the dispatcher_test.go file, please add:

func TestNewDispatcher(t *testing.T) {

	args := &KafkaDispatcherArgs{
		ClientID:     "kafka-ch-dispatcher",
		Brokers:      []string{"127.0.0.1:9092"},
		TopicFunc:    utils.TopicName,
		Logger:       nil,
	}
	_, err := NewDispatcher(args)
	if err == nil {
		t.Errorf("Expected error want %s, got %s", "message receiver is not set", err)
	}
}

@matzew
Copy link
Member

matzew commented Aug 23, 2019

/test pull-knative-eventing-contrib-go-coverage

@slinkydeveloper slinkydeveloper force-pushed the kafka-refactor-src-ch-consumer branch from 7547029 to 8ae96b5 Compare August 23, 2019 13:07
@matzew
Copy link
Member

matzew commented Aug 23, 2019

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2019
@slinkydeveloper slinkydeveloper force-pushed the kafka-refactor-src-ch-consumer branch from 8ae96b5 to 0206845 Compare September 2, 2019 16:26
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 2, 2019
@slinkydeveloper slinkydeveloper force-pushed the kafka-refactor-src-ch-consumer branch from 94a5f5e to a203b32 Compare September 3, 2019 12:07
@matzew
Copy link
Member

matzew commented Sep 3, 2019

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2019
@matzew
Copy link
Member

matzew commented Sep 3, 2019

/approve

@slinkydeveloper
Copy link
Contributor Author

/assign @n3wscott

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.

/lgtm

Added a few minor comments, but they are optional and can be addressed in a future PR.

kafka/channel/pkg/dispatcher/dispatcher.go Show resolved Hide resolved
kafka/common/pkg/kafka/consumer_factory.go Show resolved Hide resolved
kafka/source/pkg/adapter/adapter.go Outdated Show resolved Hide resolved
@n3wscott
Copy link
Contributor

n3wscott commented Sep 3, 2019

/approve

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 3, 2019
@slinkydeveloper slinkydeveloper force-pushed the kafka-refactor-src-ch-consumer branch from a203b32 to e02d84b Compare September 3, 2019 16:39
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2019
@slinkydeveloper
Copy link
Contributor Author

/retest

@grantr
Copy link
Contributor

grantr commented Sep 3, 2019

Looks like Go is complaining about data races in ConsumerFactory tests

@slinkydeveloper
Copy link
Contributor Author

My bad, in sarama documentation it says that if kafkaConfig.Consumer.Return.Errors is true, then the consumer errors are notified directly through the channel. I suppose we can just comment the error when we call consumerGroup.Consume

… kafkasource and kafkachannel (dispatcher)

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
@slinkydeveloper slinkydeveloper force-pushed the kafka-refactor-src-ch-consumer branch from 56f2e8e to 9892b87 Compare September 4, 2019 07:35
@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
kafka/channel/pkg/dispatcher/dispatcher.go 68.1% 69.7% 1.6
kafka/common/pkg/kafka/consumer_factory.go Do not exist 100.0%
kafka/common/pkg/kafka/consumer_handler.go Do not exist 100.0%
kafka/source/pkg/adapter/adapter.go 41.2% 69.2% 28.0

@matzew
Copy link
Member

matzew commented Sep 4, 2019

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 4, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, matzew, n3wscott, 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:

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 merged commit ba38933 into knative:master Sep 4, 2019
@slinkydeveloper slinkydeveloper deleted the kafka-refactor-src-ch-consumer branch September 4, 2019 09:11
@matzew matzew mentioned this pull request Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Kafka source doesn't commit offset when message is malformed Remove deprecated Kafka client libray
9 participants