Skip to content
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-8988. Replace CreatePartitions Request/Response with automated protocol #7493

Merged

Conversation

soondenana
Copy link
Contributor

This change update the CreatePartitions request and response api objects
to use automated protocol. The change involved updating all client code
to use the newly updated CreatePartitionsRequest and
CreatePartitionsResponse classes.

Updated relevant tests. All tests pass.

More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@soondenana
Copy link
Contributor Author

CC: @ijuma, @mumrah, @hachikuji, @cmccabe, @jsancio

@soondenana soondenana force-pushed the CreatePartitionsAutotmatedProtocol branch from 06fc308 to 60dde86 Compare October 11, 2019 17:33
@soondenana soondenana force-pushed the CreatePartitionsAutotmatedProtocol branch from 60dde86 to d312439 Compare November 13, 2019 01:53
@soondenana
Copy link
Contributor Author

SaslSslAdminClientIntegrationTest.testCreatePartitions failed for JDK 8
SaslScramSslEndToEndAuthorizationTest.testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl
fails for JDK 11

Ran them locally (with JDK 8) to make sure that they pass.

Copy link
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

Thanks for the patch. Left a few comments.

core/src/main/scala/kafka/server/AdminManager.scala Outdated Show resolved Hide resolved
core/src/main/scala/kafka/server/AdminManager.scala Outdated Show resolved Hide resolved
core/src/main/scala/kafka/server/AdminManager.scala Outdated Show resolved Hide resolved
return new CreatePartitionsRequest.Builder(requestMap, timeoutMs, options.validateOnly());
CreatePartitionsRequestData requestData = new CreatePartitionsRequestData()
.setTopics(topics)
.setValidateOnly(options.validateOnly())
Copy link
Contributor

Choose a reason for hiding this comment

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

Leaving this here for lack of an alternative. I was looking at the defaults used in the schema definitions. We do not override them in any cases, but I wonder if it would make sense in the case of validateOnly. If we do not override, the default would be false, but maybe true is a safer value?

Another thing I was looking at is how we handle the ErrorMessage field in the response. The previous serialization logic used ApiError which attempts to avoid serialization when the error message matches the standard value. I suspect that we might have broken this optimization in other cases as well, though I'm not sure how much it matters. Also, the old code used null as the default instead of the empty string. Perhaps we should do the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that its safer to have validateOnly default to true, but I think the common case is to have it false. If I am user of this api, I will assume the api call to create partitions by default. And if there is a need for validation only, only then I will look deeper into api to find a flag for doing that. So in that sense it matches user expectation.

Interesting comment about the ErrorMessage. But when creating CreatePartitionsResponse in CreatePartitionsRequest::getErrorResponse, we use apiError.message to populate the error message, and the method returns null if the message is default. It seems if we use apiError.messageWithFallback then we will get into situation that you are describing. I may be missing something here.

Updated json to set null for ErrorMessage field. Thanks for pointing that out.

@soondenana soondenana force-pushed the CreatePartitionsAutotmatedProtocol branch from d312439 to 36d8092 Compare January 2, 2020 18:54
Copy link
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

Thanks, left a few more small comments.

core/src/main/scala/kafka/server/AdminManager.scala Outdated Show resolved Hide resolved
core/src/main/scala/kafka/server/KafkaApis.scala Outdated Show resolved Hide resolved
core/src/main/scala/kafka/server/KafkaApis.scala Outdated Show resolved Hide resolved
…protocol

This change update the CreatePartitions request and response api objects
to use automated protocol. The change involved updating all client code
to use the newly updated CreatePartitionsRequest and
CreatePartitionsResponse classes.

Updated relevant tests. All tests pass.
The commit contain three changes:

1. Rename "integers" variable to "brokerIds"
2. Take out "()" from method calls as per coding convention
3. Refactor AdminManager::createPartitions to get rid of chained maps.
@soondenana soondenana force-pushed the CreatePartitionsAutotmatedProtocol branch from 721dc10 to 6d469f0 Compare January 6, 2020 21:30
Copy link
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

LGTM

@hachikuji
Copy link
Contributor

retest this please

Empty reassignment was treated as error condition before, filtering it
out now ignores this case and creates new partiton using default
assignment.

This change removes that filter, so that the error condition is
triggered again and `InvalidReplicaAssignmentException` gets thrown.
@soondenana
Copy link
Contributor Author

PlaintextAdminIntegrationTest.testCreatePartitions failed when empty partition assignment was passed. New code was filtering empty reassignment list, in old code it was an error condition. Fixed by removing the filter.

@soondenana
Copy link
Contributor Author

retest this please

2 similar comments
@hachikuji
Copy link
Contributor

retest this please

@hachikuji
Copy link
Contributor

retest this please

@soondenana
Copy link
Contributor Author

On 2.12 the TopicCommandWithAdminClientTest.testCreateWithReplicaAssignment test failed with error: "org.apache.kafka.common.errors.UnknownTopicOrPartitionException: This server does not host this topic-partition". Passes locally.

@hachikuji hachikuji merged commit e63becb into apache:trunk Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants