Skip to content

KAFKA-3307: Add ApiVersions Request/Response and server side handling.#986

Closed
SinghAsDev wants to merge 8 commits into
apache:trunkfrom
SinghAsDev:KAFKA-3307
Closed

KAFKA-3307: Add ApiVersions Request/Response and server side handling.#986
SinghAsDev wants to merge 8 commits into
apache:trunkfrom
SinghAsDev:KAFKA-3307

Conversation

@SinghAsDev
Copy link
Copy Markdown
Contributor

@SinghAsDev SinghAsDev commented Feb 29, 2016

The patch does the following.

  1. Adds ApiVersionsRequest/Response.
  2. Adds UNSUPPORTED_VERSION error and UnsupportedVersionException.
  3. Adds broker side handling of ApiVersionsRequest.

@SinghAsDev SinghAsDev changed the title Kafka 3307: Add ProtocolVersion request/response and server side handling. KAFKA-3307: Add ProtocolVersion request/response and server side handling. Feb 29, 2016
@SinghAsDev SinghAsDev closed this Feb 29, 2016
@SinghAsDev SinghAsDev reopened this Feb 29, 2016

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."),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need the name field? How would it be used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It has the human readable api name. Depending on use case it might be handy.

@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@gwenshap @edenhill @hachikuji mind reviewing this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this right? Doesn't this mean that cluster Describe access needs to be given to all clients?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Updating it.

@gwenshap
Copy link
Copy Markdown
Contributor

Do you mind also generating protocol docs and making sure the new protocol is documented correctly?

@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@gwenshap, I have verified that new api and error shows up on generated docs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should coordinate this with @becketqin. He has a pull request that validates the versions for all other requests and it adds UnsupportedVersionException: #200

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, let's please try to use concise and descriptive names. UnsupportedVersionException sounds good to me, personally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I will rename this to UnsupportedVersionException.

@gwenshap
Copy link
Copy Markdown
Contributor

@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 :)

@edenhill
Copy link
Copy Markdown
Contributor

Go ahead with renaming it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would remove this and the 4th constructor as it's good for a message including some more information to be included.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As you said, the errors package is public so we cannot change it.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 26, 2016

@SinghAsDev, can you please update the PR title and description to match what's actually in the PR?

@SinghAsDev SinghAsDev changed the title KAFKA-3307: Add ProtocolVersion request/response and server side handling. KAFKA-3307: Add ApiVersions Request/Response and server side handling. Apr 26, 2016
@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@ijuma I believe all review comments are addressed now. Mind taking a look again?

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 27, 2016

@SinghAsDev, can you please merge trunk into this branch as it no longer merges cleanly.

Ashish Singh added 6 commits April 26, 2016 17:44
…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.
@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@ijuma done.

SASL_HANDSHAKE(17, "SaslHandshake");
SASL_HANDSHAKE(17, "SaslHandshake"),
API_VERSION(18, "ApiVersion"),
API_VERSIONS(17, "ApiVersions");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think something went wrong here.

@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@ijuma seems like I messed up while rebasing, should be fixed now. Thanks for the reviews!

@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@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))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The message seems wrong here. Can you also please use string interpolation instead of concatenation (there are other cases in this file).

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 27, 2016

@SinghAsDev, looks good apart from one minor comment.

@SinghAsDev
Copy link
Copy Markdown
Contributor Author

@ijuma made the change, built and ran tests locally.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 27, 2016

LGTM

@gwenshap
Copy link
Copy Markdown
Contributor

LGTM. Thanks for the contribution!

@asfgit asfgit closed this in 8407dac Apr 27, 2016
gfodor pushed a commit to AltspaceVR/kafka that referenced this pull request Jun 3, 2016
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants