KAFKA-9768: Fix handling of rest.advertised.listener config#8360
Conversation
|
@rhauch @kkonstantine would you mind taking a look at this when you have a chance? |
kkonstantine
left a comment
There was a problem hiding this comment.
The fix seems adequate as a bugfix, although the name is not set by Jetty.
The name is a convention which is set by us in the same class (see Connector#setName). That's where the underscore is used as a delimiter. Unless I'm missing some log message, the connector name probably doesn't even need to contain the hostname and the port. In fact for the admin server, the connector name is just Admin.
We could consider setting the name to something that we'd match exactly and in a unique way with a mapping or enum to the protocol.
For example names Secured, Plain, Admin for https, http only and admin.
|
Yes @kkonstantine, I'd updated the description of the PR a few hours before you left your comment linking to the LOC in the I don't see a significant advantage to adding an enum or changing how the It would probably have been cleaner to implement this logic initially with an enum or some other strict mapping, but it'd probably introduce more risk than it'd be worth to do that now for what is intended to be a small bug fix. |
|
As I mentioned, this fix looks sufficient to me to fix the bug and get backported at the moment. The ideal solution, without going into implementation details, would be a way to have an exact match from protocol to connector, given that the connector name can be anything. Again, not suggested for this PR. @C0urante have you checked whether this issue has a configuration workaround (whether the order of listeners matters) and whether it's a regression (and since when) or it's been like that since the ssl endpoint was introduced? |
Understood, I'm still skeptical that it'd be beneficial to perform this refactoring any time soon without any functional changes to the Connect REST server to warrant them. But if someone else wants to take on that work and they can do it without breaking anything, it'd certainly make the code base easier to read.
Yep, the order of listeners can be used as a workaround. Added to the ticket.
It's been like that since the SSL endpoint was introduced; the blame is a little misleading since @wicknicks did some work on the REST server to add the admin listener, but the bug was present before that work as well. Also added to the ticket, along with a specific version number (1.1.0). |
|
Thanks for the discussion, @kkonstantine and @rhauch. I've added a Javadoc to the How does this look? |
|
ok to test |
rhauch
left a comment
There was a problem hiding this comment.
One more nit, just to clarify the intention in the test.
Co-Authored-By: Randall Hauch <rhauch@gmail.com>
|
Thanks @rhauch, I've accepted the suggestion. |
|
retest this please |
|
Only a couple streams integration test failures in every jdk. |
The rest.advertised.listener config is currently broken as setting it to http when listeners are configured for both https and http will cause the framework to choose whichever of the two listeners is listed first. The changes here attempt to fix this by checking not only that ServerConnector::getName begins with the specified protocol, but also that that protocol is immediately followed by an underscore, which the framework uses as a delimiter between the protocol and the remainder of the connector name. An existing unit test for the RestServer::advertisedUrl method has been expanded to include a case that fails with the framework in its current state and passes with the changes in this commit. * KAFKA-9768: Fix handling of rest.advertised.listener config * KAFKA-9768: Add comments on server connector names * KAFKA-9768: Update RestServerTest comment Co-authored-by: Randall Hauch <rhauch@gmail.com> Reviewers: Randall Hauch <rhauch@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Andrew Choi <andchoi@linkedin.com>
The rest.advertised.listener config is currently broken as setting it to http when listeners are configured for both https and http will cause the framework to choose whichever of the two listeners is listed first. The changes here attempt to fix this by checking not only that ServerConnector::getName begins with the specified protocol, but also that that protocol is immediately followed by an underscore, which the framework uses as a delimiter between the protocol and the remainder of the connector name. An existing unit test for the RestServer::advertisedUrl method has been expanded to include a case that fails with the framework in its current state and passes with the changes in this commit. * KAFKA-9768: Fix handling of rest.advertised.listener config * KAFKA-9768: Add comments on server connector names * KAFKA-9768: Update RestServerTest comment Co-authored-by: Randall Hauch <rhauch@gmail.com> Reviewers: Randall Hauch <rhauch@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Andrew Choi <andchoi@linkedin.com>
* 'trunk' of github.com:apache/kafka: (87 commits) KAFKA-9865: Expose output topic names from TopologyTestDriver (apache#8483) MINOR - Increase the number of Trogdor Histogram buckets to 10000 (apache#8627) KAFKA-9768: Fix handling of rest.advertised.listener config (apache#8360) KAFKA-9419: Fix possible integer overflow in CircularIterator (apache#7950) MINOR: Only add 'Data' suffix for generated request/response/header types (apache#8625) KAFKA-9947; Ensure proper shutdown of services in `TransactionsBounceTest` (apache#8602) KAFKA-6342; Remove unused workaround for JSON parsing of non-escaped strings (apache#8591) MINOR: Pass `-release 8` to scalac and upgrade to Gradle 6.4 (apache#8538) KAFKA-9946; Partition deletion event should only be sent if deletion was requested in the StopReplica request (apache#8609) MINOR: Improve TopologyTestDriver JavaDocs (apache#8619) MINOR: MockAdminClient should return InvalidReplicationFactorException if brokers.size < replicationFactor KAFKA-9748: Add Streams eos-beta integration test (apache#8496) KAFKA-9731: Disable immediate fetch response for hw propagation if replica selector is not defined (apache#8607) HOTFIX: set correct numIterations in shouldAllowConcurrentAccesses MINOR: Clean up some test dependencies on ConfigCommand and TopicCommand (apache#8527) KAFKA-9918; SslEngineFactory is NOT closed when channel is closing (apache#8551) KAFKA-9798: Send one round synchronously before starting the async producer (apache#8565) MINOR: Annotate KafkaAdminClientTest.testAlterClientQuotas() with @test KAFKA-9589: Enable testLogAppendTimeNonCompressedV2 and fix bug in helper method (apache#8533) MINOR: Use min/max function when possible (apache#8577) ... # Conflicts: # core/src/main/scala/kafka/log/Log.scala # gradle/dependencies.gradle # gradle/wrapper/gradle-wrapper.properties # gradlew
) The rest.advertised.listener config is currently broken as setting it to http when listeners are configured for both https and http will cause the framework to choose whichever of the two listeners is listed first. The changes here attempt to fix this by checking not only that ServerConnector::getName begins with the specified protocol, but also that that protocol is immediately followed by an underscore, which the framework uses as a delimiter between the protocol and the remainder of the connector name. An existing unit test for the RestServer::advertisedUrl method has been expanded to include a case that fails with the framework in its current state and passes with the changes in this commit. * KAFKA-9768: Fix handling of rest.advertised.listener config * KAFKA-9768: Add comments on server connector names * KAFKA-9768: Update RestServerTest comment Co-authored-by: Randall Hauch <rhauch@gmail.com> Reviewers: Randall Hauch <rhauch@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Andrew Choi <andchoi@linkedin.com>
) The rest.advertised.listener config is currently broken as setting it to http when listeners are configured for both https and http will cause the framework to choose whichever of the two listeners is listed first. The changes here attempt to fix this by checking not only that ServerConnector::getName begins with the specified protocol, but also that that protocol is immediately followed by an underscore, which the framework uses as a delimiter between the protocol and the remainder of the connector name. An existing unit test for the RestServer::advertisedUrl method has been expanded to include a case that fails with the framework in its current state and passes with the changes in this commit. * KAFKA-9768: Fix handling of rest.advertised.listener config * KAFKA-9768: Add comments on server connector names * KAFKA-9768: Update RestServerTest comment Co-authored-by: Randall Hauch <rhauch@gmail.com> Reviewers: Randall Hauch <rhauch@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Andrew Choi <andchoi@linkedin.com>
Jira
The
rest.advertised.listenerconfig is currently broken as setting it tohttpwhen listeners are configured for bothhttpsandhttpwill cause the framework to choose whichever of the two listeners is listed first. The changes here attempt to fix this by checking not only thatServerConnector::getNamebegins with the specified protocol, but also that that protocol is immediately followed by an underscore, which the framework uses as a delimiter between the protocol and the remainder of the connector name.An existing unit test for the
RestServer::advertisedUrlmethod has been expanded to include a case that fails with the framework in its current state and passes with the changes in this PR.See
kafka/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestServer.java
Line 181 in ee0ef09
kafka/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestServer.java
Line 186 in ee0ef09
ServerConnectorinstances it creates.Committer Checklist (excluded from commit message)