Skip to content

KAFKA-13809: Propagate full connector configuration to tasks in FileStream connectors#12450

Merged
C0urante merged 6 commits intoapache:trunkfrom
yashmayya:KAFKA-13809
Aug 15, 2022
Merged

KAFKA-13809: Propagate full connector configuration to tasks in FileStream connectors#12450
C0urante merged 6 commits intoapache:trunkfrom
yashmayya:KAFKA-13809

Conversation

@yashmayya
Copy link
Copy Markdown
Contributor

More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.

  • https://issues.apache.org/jira/browse/KAFKA-13809 : The FileStream connectors don't propagate all connector configs to their tasks.
  • https://issues.apache.org/jira/browse/KAFKA-9228 : client overrides, converter configs, SMT configs may not be propagated to tasks on connector config updates. This isn't an issue for most connectors because connector configs are propagated to the tasks in the connector implementations. This isn't the case for the FileStream connectors, however.
  • This PR updates the FileStream connectors to be in-line with how most other connectors generate task configs (which is a good thing because these connectors are intended to be example connector implementations), and also works around the bug from https://issues.apache.org/jira/browse/KAFKA-9228
  • Minor: Also update the inaccurate source and sink connector Javadocs to align with the source and sink task Javadocs

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

  • Manually tested the sink and source connectors and ensured that updates to SMT configs are reflected without manually restarting the tasks.

Committer Checklist (excluded from commit message)

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

@yashmayya
Copy link
Copy Markdown
Contributor Author

@C0urante could you please take a look at this small change whenever you get a chance?

@C0urante
Copy link
Copy Markdown
Contributor

C0urante commented Jul 28, 2022

Hi Yash! Thanks for the fix. It's been a long time coming that we patched the KAFKA-9228 gap with the file connectors. I'm wondering about some of the other changes, though.

We use these connectors as examples for developers on our docs site, and the section at https://kafka.apache.org/32/documentation.html#connect_connectorexample includes several code snippets taken directly from them. Even though it's not strictly necessary to pull out the topic, filename, etc. in the Connector implementations and we get the same behavior (KAFKA-9228 notwithstanding) by passing the original properties through to tasks transparently, it does help illustrate how to implement a connector to unfamiliar developers.

Could you take a look at the docs and see if there's a way to address KAFKA-9228 (and, if you want, clean up the style of the connectors) and, at the same time, maintain the connectors' value as examples for developers? Feel free to tweak the docs in docs/connect.html if necessary.

@yashmayya
Copy link
Copy Markdown
Contributor Author

Hi Chris! Thanks for taking a look, and also for pointing out that the docs need to be updated - I'd completely missed that code snippets from these FileStream connectors were being used there. I've made some changes, could you PTAL?

static final ConfigDef CONFIG_DEF = new ConfigDef()
.define(FILE_CONFIG, Type.STRING, null, Importance.HIGH, "Source filename. If not specified, the standard input will be used")
.define(TOPIC_CONFIG, Type.LIST, Importance.HIGH, "The topic to publish data to")
.define(TOPIC_CONFIG, Type.STRING, ConfigDef.NO_DEFAULT_VALUE, new ConfigDef.NonEmptyString(), Importance.HIGH, "The topic to publish data to")
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.

Not sure why this was defined as a LIST config when config values with more than one topic were anyway being rejected. I've updated this to be a STRING config and this should be backward compatible for config values that were valid previously.

if (filename != null)
config.put(FILE_CONFIG, filename);
config.put(TOPIC_CONFIG, topic);
config.put(TASK_BATCH_SIZE_CONFIG, String.valueOf(batchSize));
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.

Removed the redundant parsing from String to int (in start()) and then back to String here; it's cleaner to use the helper methods from AbstractConfig directly in the task class.

Copy link
Copy Markdown
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

Thanks Yash! I want to clarify that I don't think we need the source code for the file connectors and the code snippets for them in our docs to completely match, but rather, that we should make sure that our docs remain valuable for connector developers and that any changes that we apply to the file connectors that may be beneficial to those developers be accurately reflected back in the docs.

Comment thread docs/connect.html Outdated
Comment thread docs/connect.html Outdated
Comment thread docs/connect.html
Comment thread docs/connect.html Outdated
Comment thread docs/connect.html
Copy link
Copy Markdown
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

Thanks Yash--getting close!

Comment thread docs/connect.html Outdated
Comment thread docs/connect.html Outdated
Comment thread docs/connect.html Outdated
Copy link
Copy Markdown
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Yash!

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