KAFKA-4914: Partition re-assignment tool should check types before pe…#2708
Conversation
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
Hey @ijuma - would you mind taking a look? I see you've worked on this previously. |
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
@nicktrav Thanks for the patch. LGTM. We also faced this issue in production. Can you rebase the PR? |
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
a5bb980 to
9cb5002
Compare
|
@omkreddy - thanks for checking this one out! I completely forgot that I had this open. I've rebased. Would love to get it merged, as it was the source of a reasonable amount of (avoidable) pain for us a few months ago, and would love to save some others from that. Are you able to merge this in when green? |
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
LGTM. Though we are deprecating "--zookeeper" option in KIP-179 (Change ReassignPartitionsCommand to use adminClient), It is good to have this check. cc @ijuma pinging for review. |
|
Thanks for the PR. I think we should consider using Jackson to parse into classes with the expected structure. That will do the necessary validation in a more robust way. Thoughts? |
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
Sounds reasonable, @ijuma. I'll take another pass at it. |
9cb5002 to
0231adf
Compare
|
Refer to this link for build results (access rights to CI server needed): |
|
Refer to this link for build results (access rights to CI server needed): |
|
Thanks, I'll take a look tomorrow. |
|
@ijuma - sorry to keep pinging you on this. How is this looking? Happy to address any feedback you might have. |
|
Ping @omkreddy |
0231adf to
17fc8cf
Compare
|
Retest this please. |
There was a problem hiding this comment.
The result type can be Either[JsonProcessingException, T].
There was a problem hiding this comment.
Seems like we'd want to include the original exception as the cause. Also, why is it a ConfigException?
There was a problem hiding this comment.
We should be using this in ReassignPartitionsZNode as in my PR.
There was a problem hiding this comment.
We should use ReassignPartitionsZNode.decode
There was a problem hiding this comment.
We should rewrite these tests to use ReassignPartitionsZNode. Also, since they don't require ZooKeeper, they should be unit tests. Perhaps ReassignPartitionsZNodeTest.
|
Thanks for the review @ijuma. I pushed a new commit addressing your last round of comments. I'm sure some of it is not idiomatic Scala, so would appreciate some guidance, if any. |
|
Can we use zkUtils.parsePartitionReassignmentData here |
|
@omkreddy Ideally, we should not be using |
|
LGTM. +1 |
|
Sorry, I have just moved countries and won't have time until next week. |
|
No worries at all. Good luck with the move! |
2954d4c to
b7b210e
Compare
…rsisting state in ZooKeeper Prior to this, there have been instances where invalid data was allowed to be persisted in ZooKeeper, which causes ClassCastExceptions when a broker is restarted and reads this type-unsafe data. Adds basic structural and type validation for the reassignment JSON via introduction of Scala case classes that map to the expected JSON structure.
b7b210e to
ec7f36d
Compare
|
maybe @hachikuji can help to merge this patch. |
viktorsomogyi
left a comment
There was a problem hiding this comment.
Although (as mentioned on my JIRA) this PR seems to aim bit different goals then mine, I reviewed this PR and made one minor comment/question.
All in all I think the PR looks good. Would be happy to see this merged.
| * Parse a JSON string into either a generic type T, or a JsonProcessingException in the case of | ||
| * exception. | ||
| */ | ||
| def parseStringAs[T](input: String)(implicit tag: ClassTag[T]): Either[JsonProcessingException, T] = { |
There was a problem hiding this comment.
Hmm, just a very basic question: why are you using here Either/Left/Right instead of Try/Success/Failure?
As from my previous experiences we used Try when we wanted to propagate the exception.
And please not I don't mind using Either, just asking for reasons. :)
There was a problem hiding this comment.
My (idiomatic) Scala isn't great, but this came at the suggestion of @ijuma (above):
#2708 (comment)
There was a problem hiding this comment.
Try doesn't let you specify an exception subclass and behaves a bit different if an exception is thrown during map, etc.
ijuma
left a comment
There was a problem hiding this comment.
I pushed minor changes and it now LGTM. Will merge it after the tests pass. Thanks so much for your patience.
|
Thanks @ijuma! |
…rsisting state in ZooKeeper
Prior to this, there have been instances where invalid data was allowed to be persisted in ZooKeeper, which causes ClassCastExceptions when a broker is restarted and reads this type-unsafe data.
Adds basic structural and type validation for the reassignment JSON via introduction of Scala case classes that map to the expected JSON structure.