KAFKA-3307: Add ApiVersions Request/Response and server side handling.#986
KAFKA-3307: Add ApiVersions Request/Response and server side handling.#986SinghAsDev wants to merge 8 commits into
Conversation
|
|
||
| public static final Schema SINGLE_PROTOCOL_VERSION_V0 = new Schema( | ||
| new Field("api_key", INT16, "Api key of protocol."), | ||
| new Field("api_name", STRING, "Api name of protocol."), |
There was a problem hiding this comment.
Do we need the name field? How would it be used?
There was a problem hiding this comment.
It has the human readable api name. Depending on use case it might be handy.
|
@gwenshap @edenhill @hachikuji mind reviewing this? |
There was a problem hiding this comment.
Is this right? Doesn't this mean that cluster Describe access needs to be given to all clients?
There was a problem hiding this comment.
It is usually treated as security flaw to be able to know what version is supported by server, as with that knowledge one can exploit security flaws associated with the version. Does cluster describe seem too restrictive? Trying to think what else can be done here. Do you have any suggestion?
There was a problem hiding this comment.
I think the security gain from restricting this API is a little dubious, but I can understand the desire to limit information leakage. Anyway, perhaps there's no need to rehash the argument since the KIP already says this?
The broker returns its full list of supported ApiKeys and versions regardless of current authentication state (e.g., before SASL authentication). If this is considered to leak information SSL can be used for early authentication.
There was a problem hiding this comment.
Agreed. Updating it.
|
Do you mind also generating protocol docs and making sure the new protocol is documented correctly? |
|
@gwenshap, I have verified that new api and error shows up on generated docs. |
There was a problem hiding this comment.
I would prefer to make it a bit more generic (i.e. UnknownApiVersion or UnknownRequestVersion or something like that)
This will allow us to reuse this error for other Requests in the future.
Do you see any reason not to?
There was a problem hiding this comment.
We should coordinate this with @becketqin. He has a pull request that validates the versions for all other requests and it adds UnsupportedVersionException: #200
There was a problem hiding this comment.
Yes, let's please try to use concise and descriptive names. UnsupportedVersionException sounds good to me, personally.
There was a problem hiding this comment.
Makes sense. I will rename this to UnsupportedVersionException.
|
@SinghAsDev - ApiVersion and ApiVersions is a tiny change and no one is using the API yet (since we didn't commit yet...), I see no problems. Whatever you see fit is fine by me :) |
|
Go ahead with renaming it. |
There was a problem hiding this comment.
I would remove this and the 4th constructor as it's good for a message including some more information to be included.
There was a problem hiding this comment.
Makes sense, in fact do you think it makes sense to have a follow up JIRA to do this exercise for all exceptions? One can argue that it is a public class in common, but I do not think it should be too big of a deal. If you agree, I can file a follow up JIRA and take on that in some time.
There was a problem hiding this comment.
As you said, the errors package is public so we cannot change it.
|
@SinghAsDev, can you please update the PR title and description to match what's actually in the PR? |
|
@ijuma I believe all review comments are addressed now. Mind taking a look again? |
|
@SinghAsDev, can you please merge trunk into this branch as it no longer merges cleanly. |
…quest version is greater than supported ApiRequest version
1. Rename Errors.UNKNOWN_API_VERSION_REQUEST_VERSION => Errors.UNSUPPORTED_VERSION. 2. Use JUnit.assert instead of scala's assert in tests. 3. Maintain map of ApiKey to ApiVersion in ApiVersionResponse. 4. Add note in KafkaApis on why authentication is not performed while handling ApiVersionRequest
…equest and ApiVersionResponse => ApiVersionsResponse
force adding some useful info while throwing exception.
|
@ijuma done. |
| SASL_HANDSHAKE(17, "SaslHandshake"); | ||
| SASL_HANDSHAKE(17, "SaslHandshake"), | ||
| API_VERSION(18, "ApiVersion"), | ||
| API_VERSIONS(17, "ApiVersions"); |
There was a problem hiding this comment.
I think something went wrong here.
|
@ijuma seems like I messed up while rebasing, should be fixed now. Thanks for the reviews! |
|
@ijuma does this look good now? |
| val version = KafkaApis.apiVersionsResponse.apiVersion(key.id) | ||
| assertNotNull("Could not find ApiVersion for API " + key.name, version) | ||
| assertEquals("Incorrect min version for Api " + key.name, version.minVersion, Protocol.MIN_VERSIONS(key.id)) | ||
| assertEquals("Incorrect min version for Api " + key.name, version.maxVersion, Protocol.CURR_VERSION(key.id)) |
There was a problem hiding this comment.
The message seems wrong here. Can you also please use string interpolation instead of concatenation (there are other cases in this file).
|
@SinghAsDev, looks good apart from one minor comment. |
|
@ijuma made the change, built and ran tests locally. |
|
LGTM |
|
LGTM. Thanks for the contribution! |
The patch does the following. 1. Adds ApiVersionsRequest/Response. 2. Adds UNSUPPORTED_VERSION error and UnsupportedVersionException. 3. Adds broker side handling of ApiVersionsRequest. Author: Ashish Singh <asingh@cloudera.com> Reviewers: Gwen Shapira, Ismael Juma, Magnus Edenhill Closes apache#986 from SinghAsDev/KAFKA-3307
The patch does the following.