KAFKA-8404: Add HttpHeader to RestClient HTTP Request and Connector REST API#6791
Conversation
|
retest me |
rayokota
left a comment
There was a problem hiding this comment.
@haidangdam , this looks good! Left a few minor comments.
@rayokota Hi. Thanks for the input. I have already pushed the changed version. |
rayokota
left a comment
There was a problem hiding this comment.
@haidangdam , left a few more nits. Thanks!
There was a problem hiding this comment.
nit: add param description
There was a problem hiding this comment.
nit: add param description
|
@rhauch Hi, would you mind taking a look at this PR. Thanks |
rhauch
left a comment
There was a problem hiding this comment.
Thanks for the fix, @haidangdam! Just a few small comments/suggestions, but otherwise looks good.
There was a problem hiding this comment.
Maybe instead of null we could use NO_HEADERS instead?
There was a problem hiding this comment.
I'm not sure about this. Would you like to have HttpHeaders nullHeaders = null;
There was a problem hiding this comment.
I would like to see:
connectorsResource.createConnector(FORWARD, NULL_HEADERS, bodyIn);
to make it much more clear what the second parameter is and that most of the tests are not specifying headers.
There was a problem hiding this comment.
Done. Thanks for clearer instruction.
C0urante
left a comment
There was a problem hiding this comment.
Looks pretty good @haidangdam, just one question.
There was a problem hiding this comment.
If the REST API requires authorization, won't this request fail due to lack of headers?
There was a problem hiding this comment.
Hi. Pattern will filter out this endpoint so that authorization will not fail.
There was a problem hiding this comment.
Hi @haidangdam, you mean there is no Authorization for POST /connectors/xx/tasks, so anyone can change tasks configuration ??
There was a problem hiding this comment.
Currently this endpoint should be secured through other means, such as mutual TLS.
de9032a to
78c867e
Compare
There was a problem hiding this comment.
I don't think the backslashes in this regex string are necessary; can it be simplified to "/?connectors/[^/]+/tasks/?"?
There was a problem hiding this comment.
Actually, why don't we initialize the final as a Pattern instance so that we don't have to parse the pattern with every request?
There was a problem hiding this comment.
That's a good addition too. We should definitely clean up the regex if possible too, though.
There was a problem hiding this comment.
yup. changed as well! Thanks for the suggestion
rhauch
left a comment
There was a problem hiding this comment.
Thanks for the update, @haidangdam. A few questions and suggestions.
There was a problem hiding this comment.
I would like to see:
connectorsResource.createConnector(FORWARD, NULL_HEADERS, bodyIn);
to make it much more clear what the second parameter is and that most of the tests are not specifying headers.
There was a problem hiding this comment.
Actually, why don't we initialize the final as a Pattern instance so that we don't have to parse the pattern with every request?
C0urante
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix @haidangdam!
Ideally we'll follow up to lock down the putTaskConfig resource, but that's probably out of scope for this PR and, while incomplete, this is strictly an improvement over the state of authentication in the existing REST API code.
rhauch
left a comment
There was a problem hiding this comment.
LGTM. Thanks, @haidangdam!
Resolved conflict
0674512 to
d30d6ce
Compare
|
The JDK 11 build failed on a Stream test, and all Connect tests passed with these changes in that build. The Connect tests all passed in the JDK 8 build, also. @rayokota, @haidangdam: let's rebase this PR branch and run the Connect system tests with it. The rebase is necessary to pick up some Connect system test fixes that were merged since this branch was last rebased. |
…EST API (#6791) When Connect forwards a REST request from one worker to another, the Authorization header was not forwarded. This commit changes the Connect framework to add include the authorization header when forwarding requests to other workers. Author: Hai-Dang Dam <damquanghaidang@gmail.com> Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@gmail.com>
…EST API (#6791) When Connect forwards a REST request from one worker to another, the Authorization header was not forwarded. This commit changes the Connect framework to add include the authorization header when forwarding requests to other workers. Author: Hai-Dang Dam <damquanghaidang@gmail.com> Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@gmail.com> # Conflicts: # connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java # connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java
…EST API (#6791) When Connect forwards a REST request from one worker to another, the Authorization header was not forwarded. This commit changes the Connect framework to add include the authorization header when forwarding requests to other workers. Author: Hai-Dang Dam <damquanghaidang@gmail.com> Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@gmail.com> # Conflicts: # connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java # connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java # Conflicts: # connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java
…EST API (#6791) When Connect forwards a REST request from one worker to another, the Authorization header was not forwarded. This commit changes the Connect framework to add include the authorization header when forwarding requests to other workers. Author: Hai-Dang Dam <damquanghaidang@gmail.com> Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@gmail.com> # Conflicts: # connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java # connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java # Conflicts: # connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java
* AK_REPO/2.3: KAFKA-8155: Add 2.2.0 release to system tests (apache#6597) KAFKA-8404: Add HttpHeader to RestClient HTTP Request and Connector REST API (apache#6791) KAFKA-8473: Adjust Connect system tests for incremental cooperative rebalancing (apache#6872) KAFKA-8475: Temporarily restore SslFactory.sslContext() helper KAFKA-8449: Restart tasks on reconfiguration under incremental cooperative rebalancing (apache#6850) KAFKA-8426; Fix for keeping the ConfigProvider configs consistent with KIP-297 (apache#6750) KAFKA-8425: Fix for correctly handling immutable maps (KIP-421 bug) (apache#6795) MINOR: Reordering the props modification with configs construction
…EST API (apache#6791) When Connect forwards a REST request from one worker to another, the Authorization header was not forwarded. This commit changes the Connect framework to add include the authorization header when forwarding requests to other workers. Author: Hai-Dang Dam <damquanghaidang@gmail.com> Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@gmail.com>
…EST API (apache#6791) When Connect forwards a REST request from one worker to another, the Authorization header was not forwarded. This commit changes the Connect framework to add include the authorization header when forwarding requests to other workers. Author: Hai-Dang Dam <damquanghaidang@gmail.com> Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@gmail.com>
Description:
The ticket: https://issues.apache.org/jira/browse/KAFKA-8404
Add HttpHeader to Connector REST API.
Adding Authorization header to the Connector's Rest Client HTTP Request
Backporting to Kafka version 2.0
Testing:
Logic Test with Mocking.
Committer Checklist (excluded from commit message)