Skip to content

KAFKA-5295: Allow source connectors to specify topic-specific settings for new topics (KIP-158)#8722

Merged
kkonstantine merged 28 commits intoapache:trunkfrom
kkonstantine:kip-158
May 27, 2020
Merged

KAFKA-5295: Allow source connectors to specify topic-specific settings for new topics (KIP-158)#8722
kkonstantine merged 28 commits intoapache:trunkfrom
kkonstantine:kip-158

Conversation

@kkonstantine
Copy link
Copy Markdown
Contributor

Kafka Connect workers have been able to create Connect's internal topics using the new admin client for some time now (see KAFKA-4667). However, tasks of source connectors are still relying upon the broker to auto-create topics with default config settings if they don't exist, or expect these topics to exist before the connector is deployed, if their configuration needs to be specialized.

With the implementation of KIP-158 here, if topic.creation.enable=true, Kafka Connect will supply the source tasks of connectors that are configured to create topics with an admin client that will allow them to create new topics on-the-fly before writing the first source records to a new topic. Additionally, each source connector has the opportunity to customize the topic-specific settings of these new topics by defining groups of topic configurations.

This feature is tested here via unit tests (old tests that have been adjusted and new ones) as well as integration tests.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@kkonstantine
Copy link
Copy Markdown
Contributor Author

Rebased to resolve conflicts

Copy link
Copy Markdown
Contributor Author

@kkonstantine kkonstantine May 24, 2020

Choose a reason for hiding this comment

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

These had to be moved out of this class, or else tests for StandaloneHerder would break. They are now reused here as well as TopicCreationConfig

Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Nice work, @kkonstantine! I completed an initial pass, and overall this looks good. Detailed questions and comments in line comments below.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment on lines 154 to 158
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these useful?

@kkonstantine
Copy link
Copy Markdown
Contributor Author

kkonstantine commented May 24, 2020

Thanks for your comments @rhauch !
I'll be addressing them shortly. I just added unit tests for the source connector configs and I'll be adding a few more plus the integration tests that you mentioned.

I'll ping you here when it's ready for another pass. Thanks!

Copy link
Copy Markdown
Contributor Author

@kkonstantine kkonstantine left a comment

Choose a reason for hiding this comment

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

Thanks again for the first round of comments @rhauch
I think I've addressed them all with a fix or a comment.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
@kkonstantine
Copy link
Copy Markdown
Contributor Author

Results of the latest completed build:
jk8: success
jk11: the beta eos failure again
jk14: success
Coverage is now quite high, but I'm considering adding a few more tests.

@kkonstantine
Copy link
Copy Markdown
Contributor Author

Rebased just to resolve conflicts with #2604

Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Thanks for the update, @kkonstantine. Took a second pass -- things look good, and I'm finding smaller things to nit pick.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
@kkonstantine
Copy link
Copy Markdown
Contributor Author

Rebased to resolve minor conflicts from #8118

Copy link
Copy Markdown
Contributor Author

@kkonstantine kkonstantine left a comment

Choose a reason for hiding this comment

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

Thanks for the follow up @rhauch !
I've pushed the new commits to address your comments and I've rebased (and fixed a previous rebase) to resolve conflicts.

The only suggestion I haven't followed yet is the one around the ordering of static methods. I think I've followed our style here for the most part, wdyt?

Besides that, I'd like to revisit once more the new unit tests in one more commit, after the refactoring that you suggested.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java Outdated
Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Thanks, @kkonstantine. Even closer now, though I have a few comments/suggestions.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java Outdated
Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

One comment to fix my screwed-up suggestion.

Comment on lines +126 to +127
// If the user has added regex of include or exclude patterns in the default group,
// they should be ignored.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TDD :)

Copy link
Copy Markdown
Contributor Author

@kkonstantine kkonstantine left a comment

Choose a reason for hiding this comment

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

Thanks @rhauch !
I think I've addressed your latest comments.

Lmk how it looks. Hopefully we'll get a couple green builds too.

Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Great work, @kkonstantine! It's going to be really nice to get this in, so thanks for picking this up.

LGTM, pending a green build.

@kkonstantine
Copy link
Copy Markdown
Contributor Author

One test broke after the change in the config validation exception. Should be fixed now.

@kkonstantine
Copy link
Copy Markdown
Contributor Author

jdk8: success
jdk11: only two failures on a known flaky streams test (EosBetaUpgradeIntegrationTest)
jdk14: a single failure on another unrelated streams test (KTableSourceTopicRestartIntegrationTest)

Given these results I'll go ahead and merge this PR.
Thanks again for the reviews @rhauch !

@kkonstantine kkonstantine merged commit 371f14c into apache:trunk May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants