New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-16093: Fix spurious REST-related warnings on Connect startup #15149
Conversation
… spurious warnings
…ct REST resources, fixing spurious warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my... I thought these warnings were here to stay! I've seen them so many times that I couldn't understand what they meant, even though they are very direct about what is incorrect.
Thank you so much for fixing this!
...t/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectResource.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Chris! No more nuisance stderr from tests!
Thanks @gharris1727! I wanted to take a stab at fixing these errors "correctly", i.e., by registering classes instead of instances with the regular and admin |
adminResources.forEach(adminResourceConfig::register); | ||
adminResourceConfig.register(ConnectExceptionMapper.class); | ||
adminResourceConfig.property(ServerProperties.WADL_FEATURE_DISABLE, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes another spurious warning message that gets emitted if the worker is configured with the admin.listeners
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is some light duplication, perhaps the ResourceConfig constructor and the 4 lines accompanying it (request timeout, jackson, exception mapper, and wadl feature disable) can be deduplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, done. I've also cleaned up the configuration of the adminResourceConfig
to hopefully prevent other kinds of duplication-related issues in the future; LMKWYT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this approach, and I agree it's the non-hacky way forward. TIL about AbstractBinder and the dependency injection mechanism that Jersey provides.
In particular I like removing ConnectResource, and making the RestRequestTimeout object mutable instead of having all of the resources themselves mutable.
@@ -159,7 +163,8 @@ public class ConnectorsResourceTest { | |||
public void setUp() throws NoSuchMethodException { | |||
when(serverConfig.topicTrackingEnabled()).thenReturn(true); | |||
when(serverConfig.topicTrackingResetEnabled()).thenReturn(true); | |||
connectorsResource = new ConnectorsResource(herder, serverConfig, restClient); | |||
RestRequestTimeout requestTimeout = () -> RestServer.DEFAULT_REST_REQUEST_TIMEOUT_MS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks 👍
adminResources.forEach(adminResourceConfig::register); | ||
adminResourceConfig.register(ConnectExceptionMapper.class); | ||
adminResourceConfig.property(ServerProperties.WADL_FEATURE_DISABLE, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is some light duplication, perhaps the ResourceConfig constructor and the 4 lines accompanying it (request timeout, jackson, exception mapper, and wadl feature disable) can be deduplicated.
- Deduplicate RestServer instantiation and configuration of ResourceConfig instances - Remove unused RestRequestTimeout instance from ConnectorsResourceTest - Fix failing ConnectRestServerTest suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Chris!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into these log messages! Added some nit level comments.
@@ -41,18 +41,11 @@ public class HerderRequestHandler { | |||
|
|||
private final RestClient restClient; | |||
|
|||
private volatile long requestTimeoutMs; | |||
private final RestRequestTimeout requestTimeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field requestTimeoutMs
was made volatile as part of here. I don't think we need it now, but just wanted to understand why was it added over there (you can skip the explanation if it's too complex :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field is final, it wouldn't make sense to mark it volatile.
The underlying mutable value that it returns from timeoutMs()
is still marked volatile in the only non-test implementation here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't intend to mark the final field as volatile. I wanted to know why the field was marked as volatile in the old PR since you had made the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha. The intent was to make it thread-safe since it's likely that writes and reads to/of that value will take place on different threads.
private class Binder extends AbstractBinder { | ||
@Override | ||
protected void configure() { | ||
bind(herder).to(Herder.class); | ||
bind(restClient).to(RestClient.class); | ||
bind(config).to(RestServerConfig.class); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We could probably move the class definition to the bottom so that all configureXXXResources
method are together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true, but not a blocker.
if (requestTimeoutMs < 1) { | ||
throw new IllegalArgumentException("REST request timeout must be positive"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this validation was needed in the past as well, but now I don't see it being present. Do you think it's needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it for two reasons:
- This code path is only ever used in testing code
- It's unclear that the validation would be safer than allowing negative values. At least on my machine, negative values don't cause any issues with, e.g.,
ConvertingFutureCallback::get
.
*/ | ||
package org.apache.kafka.connect.runtime.rest; | ||
|
||
public interface RestRequestTimeout { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Mark this interface as @FunctionalInterface
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see some benefit to this, but it's also not a blocker.
It's also debatable, since this interface may change in the future and we don't want to imply that it can only have exactly one abstract method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Makes sense.
Thanks @gharris1727! @vamossagar12 I appreciate the review but none of these seem like blocking comments. Please try to use the "request changes" button sparingly. Thanks! Test failures appear unrelated and all come from known flaky tests. Merging... |
…15149) Reviewers: Sagar Rao <sagarmeansocean@gmail.com>, Greg Harris <greg.harris@aiven.io>
@C0urante , hmm okay. I understand those weren't blocker comments and I called them as nits. |
…pache#15149) Reviewers: Sagar Rao <sagarmeansocean@gmail.com>, Greg Harris <greg.harris@aiven.io>
…pache#15149) Reviewers: Sagar Rao <sagarmeansocean@gmail.com>, Greg Harris <greg.harris@aiven.io>
…pache#15149) Reviewers: Sagar Rao <sagarmeansocean@gmail.com>, Greg Harris <greg.harris@aiven.io>
…15149) Reviewers: Sagar Rao <sagarmeansocean@gmail.com>, Greg Harris <greg.harris@aiven.io>
Jira
Committer Checklist (excluded from commit message)