Skip to content

KAFKA-9888: Copy connector configs before passing to REST extensions#8511

Merged
kkonstantine merged 4 commits intoapache:trunkfrom
C0urante:kafka-9888
May 23, 2020
Merged

KAFKA-9888: Copy connector configs before passing to REST extensions#8511
kkonstantine merged 4 commits intoapache:trunkfrom
C0urante:kafka-9888

Conversation

@C0urante
Copy link
Copy Markdown
Contributor

Jira

The changes made in KIP-454 involved adding a connectorConfig method to the ConnectClusterState interface that REST extensions could use to query the worker for the configuration of a given connector. The implementation for this method returns the Java Map that's stored in the worker's view of the config topic (when running in distributed mode). No copying is performed, which causes mutations of that Map object to persist across invocations of connectorConfig and, even worse, propagate to the worker when, e.g., starting a connector.

The changes here just cause the framework to copy that map before sending it to REST extensions, and alter a comment in KafkaConfigBackingStore that addresses the mutability of the snapshots that it provides to warn against changes that may lead to bugs like this one.

An existing unit test is modified to ensure that REST extensions receive a copy of the connector config, not the original.

Committer Checklist (excluded from commit message)

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

@C0urante
Copy link
Copy Markdown
Contributor Author

@stan-confluent, @ncliang, @gharris1727 would any of you mind taking a look when you have a moment?

Copy link
Copy Markdown
Contributor

@ncliang ncliang left a comment

Choose a reason for hiding this comment

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

Thanks @C0urante . LGTM

@C0urante
Copy link
Copy Markdown
Contributor Author

Thanks @ncliang! @kkonstantine, @rhauch would one of you mind taking a look at this when you get a chance?

C0urante and others added 2 commits May 20, 2020 10:56
…/health/ConnectClusterStateImpl.java

Co-authored-by: Konstantine Karantasis <konstantine@confluent.io>
@C0urante
Copy link
Copy Markdown
Contributor Author

Thanks @kkonstantine, I've addressed both of your comments. Ready for another round when you have time.

@kkonstantine
Copy link
Copy Markdown
Contributor

ok to test

@kkonstantine
Copy link
Copy Markdown
Contributor

2/3 build green, yet a failure that seems unrelated but happened during a connect IT. Given that I'll rerun once more.

@kkonstantine
Copy link
Copy Markdown
Contributor

retest this please

1 similar comment
@kkonstantine
Copy link
Copy Markdown
Contributor

retest this please

@kkonstantine
Copy link
Copy Markdown
Contributor

jdk8: success
jdk11: single failure on flaky: org.apache.kafka.streams.integration.EosBetaUpgradeIntegrationTest.shouldUpgradeFromEosAlphaToEosBeta[true]
jdk14: single failure on flaky: kafka.api.PlaintextProducerSendTest.testNonBlockingProducer

Copy link
Copy Markdown
Contributor

@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.

LGTM

@kkonstantine kkonstantine merged commit 40ee580 into apache:trunk May 23, 2020
kkonstantine pushed a commit that referenced this pull request May 23, 2020
…8511)

The changes made in KIP-454 involved adding a `connectorConfig` method to the ConnectClusterState interface that REST extensions could use to query the worker for the configuration of a given connector. The implementation for this method returns the Java `Map` that's stored in the worker's view of the config topic (when running in distributed mode). No copying is performed, which causes mutations of that `Map` to persist across invocations of `connectorConfig` and, even worse, propagate to the worker when, e.g., starting a connector.

In this commit the map is copied before it's returned to REST extensions.

An existing unit test is modified to ensure that REST extensions receive a copy of the connector config, not the original.

Reviewers: Nigel Liang <nigel@nigelliang.com>, Konstantine Karantasis <konstantine@confluent.io>
kkonstantine pushed a commit that referenced this pull request May 23, 2020
…8511)

The changes made in KIP-454 involved adding a `connectorConfig` method to the ConnectClusterState interface that REST extensions could use to query the worker for the configuration of a given connector. The implementation for this method returns the Java `Map` that's stored in the worker's view of the config topic (when running in distributed mode). No copying is performed, which causes mutations of that `Map` to persist across invocations of `connectorConfig` and, even worse, propagate to the worker when, e.g., starting a connector.

In this commit the map is copied before it's returned to REST extensions.

An existing unit test is modified to ensure that REST extensions receive a copy of the connector config, not the original.

Reviewers: Nigel Liang <nigel@nigelliang.com>, Konstantine Karantasis <konstantine@confluent.io>
kkonstantine pushed a commit that referenced this pull request May 23, 2020
…8511)

The changes made in KIP-454 involved adding a `connectorConfig` method to the ConnectClusterState interface that REST extensions could use to query the worker for the configuration of a given connector. The implementation for this method returns the Java `Map` that's stored in the worker's view of the config topic (when running in distributed mode). No copying is performed, which causes mutations of that `Map` to persist across invocations of `connectorConfig` and, even worse, propagate to the worker when, e.g., starting a connector.

In this commit the map is copied before it's returned to REST extensions.

An existing unit test is modified to ensure that REST extensions receive a copy of the connector config, not the original.

Reviewers: Nigel Liang <nigel@nigelliang.com>, Konstantine Karantasis <konstantine@confluent.io>
Kvicii pushed a commit to Kvicii/kafka that referenced this pull request May 24, 2020
* 'trunk' of github.com:apache/kafka:
  KAFKA-9888: Copy connector configs before passing to REST extensions (apache#8511)
  KAFKA-9931: Implement KIP-605 to expand support for Connect worker internal topic configurations (apache#8654)
  KAFKA-6145: Add unit tests for assignments of only stateless tasks (apache#8713)
  MINOR: Fix join group request timeout lower bound (apache#8702)
  MINOR: Improve security documentation for Kafka Streams apache#8710
  KAFKA-6145: KIP-441: Enforce Standby Task Stickiness (apache#8696)
  KAFKA-10003: Mark KStream.through() as deprecated and update Scala API (apache#8679)
@C0urante C0urante deleted the kafka-9888 branch June 13, 2021 22:22
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.

3 participants