MINOR: enable topic deletion in the KIP-500 controller#10184
MINOR: enable topic deletion in the KIP-500 controller#10184hachikuji merged 5 commits intoapache:trunkfrom
Conversation
|
Successfully ran the system test that was previously failing due to an inability to delete topics:
|
chia7712
left a comment
There was a problem hiding this comment.
overall LGTM. some minor questions are left. Please take a look.
b05a027 to
f31fb91
Compare
|
rebased on trunk |
chia7712
left a comment
There was a problem hiding this comment.
Thanks for updating code. Some minor comments are left. Please take a look.
7822e76 to
08aedff
Compare
|
rebased on trunk |
08aedff to
b56ea48
Compare
|
rebased on trunk |
b56ea48 to
3c649c4
Compare
There was a problem hiding this comment.
The error should be TOPIC_AUTHORIZATION_FAILED if the client does not have describe permission regardless of existence.
There was a problem hiding this comment.
I think there are 5 cases:
- name provided, topic exists, can't delete, maybe can describe => TOPIC_AUTHORIZATION_FAILED
- name provided, topic doesn't exist, can't delete, can describe => UNKNOWN_TOPIC_OR_PARTITION
- name provided, topic doesn't exist, can't delete, can't describe => TOPIC_AUTHORIZATION_FAILED
- id provided, topic exists, can't delete, maybe can describe => TOPIC_AUTHORIZATION_FAILED
- id provided, topic doesn't exists, can't delete, maybe can describe => UNKNOWN_TOPIC_ID
There was a problem hiding this comment.
For case 4, are we exposing the topic exists by returning a different error (than case 5) in the case where we can't describe?
There was a problem hiding this comment.
You're right, the earlier list was not quite right. I've revised this a bit. It's now:
no name or id => INVALID_REQUEST
duplicate name or id => INVALID_REQUEST
can't resolve topic id => UNKNOWN_TOPIC_ID
can't locate topic name => UNKNOWN_TOPIC_OR_PARTITION
no delete permission, no describe permission => UNKNOWN_TOPIC_ID (if topic id was provided) or UNKNOWN_TOPIC_OR_PARTITION (if topic name was provided)
no delete permission, describe permission => TOPIC_AUTHORIZATION_FAILED with both name and id filled out correctly
The new code should implement this correctly...
There was a problem hiding this comment.
@cmccabe Oh sorry this just got changed due to https://issues.apache.org/jira/browse/KAFKA-12394
So the case of no delete permission, no describe permission, topic ID provided is now TOPIC_AUTHORIZATION_FAILED. This may have been what you had initially.
There was a problem hiding this comment.
Should we update brokersToIsrs too?
There was a problem hiding this comment.
The ISRs should already have been updated by BrokerChangeRecords that were previously replayed.
There was a problem hiding this comment.
Hmm, you mean PartitionChangeRecord? I don't see PartitionChangeRecord being generated from the topicDeletion request.
There was a problem hiding this comment.
Sorry, you're right: we need to remove this from brokersToIsrs. Fixed.
There was a problem hiding this comment.
I guess we haven't hooked up the logic to trigger the deletion of the replicas of the deleted topic in the broker?
There was a problem hiding this comment.
We haven't hooked that up yet, correct. But that logic is in BrokerMetadataListener. It would probably be better to have a separate PR for that.
f571a4c to
ac03b21
Compare
There was a problem hiding this comment.
Hmm, you mean PartitionChangeRecord? I don't see PartitionChangeRecord being generated from the topicDeletion request.
There was a problem hiding this comment.
We also need to delete the configuration associated with the topic.
There was a problem hiding this comment.
Is the deletion of topic configurations implicit based on the DeleteTopic record? I know we discussed this, but I'm unsure what the final outcome was. I don't see any logic for this in the broker listener, but the implementation looks incomplete anyway.
There was a problem hiding this comment.
Yes, it should be implicit based on the DeleteTopic record. I will fix the controller to do the right thing here. We'll also need to have the broker do that too.
chia7712
left a comment
There was a problem hiding this comment.
@cmccabe Thanks for updating PR.
this code ends up being complicated. Could it be separated and then reused by ControlApis and KafkaApis? I left same comment on #10223 (#10223 (comment))
|
@cmccabe I pushed a commit that removes a bunch of unnecessary |
There was a problem hiding this comment.
Is the deletion of topic configurations implicit based on the DeleteTopic record? I know we discussed this, but I'm unsure what the final outcome was. I don't see any logic for this in the broker listener, but the implementation looks incomplete anyway.
0274964 to
9424061
Compare
|
The below, if added as Maybe add this system test to this PR as |
|
@rondagostino I believe that error will be fixed by https://issues.apache.org/jira/browse/KAFKA-12403. |
|
Thanks for the reviews! I reworked the authentication, validation, and de-duplication code a lot. The new logic should take into account the issues pointed out here. I resolved a few comment threads since they refer to code that was refactored-- please take another look if you get a chance. To clarify a bit,
The fact that it wasn't doing these things was a bug... it's fixed now. This should also allow the ducktape test to work (cc @rondagostino ) We also have a JIRA to follow up on the broker side: https://issues.apache.org/jira/browse/KAFKA-12403 |
Enable the new KIP-500 controller to delete topics. Fix a bug where feature level records were not correctly replayed. Fix a bug in TimelineHashMap#remove where the wrong type was being returned.
|
junrao
left a comment
There was a problem hiding this comment.
@hachikuji : Thanks for the updated PR. Just a couple of more comments.
| brokersToIsrs.removeTopicEntryForBroker(topic.id, partition.isr[i]); | ||
| } | ||
| } | ||
| brokersToIsrs.removeTopicEntryForBroker(topic.id, NO_LEADER); |
There was a problem hiding this comment.
Hmm, why do we need to remove for -1 broker? It doesn't seem that brokersToIsrs tracks that.
There was a problem hiding this comment.
The test case BrokersToIsrsTest.testNoLeader suggests that it is a possible case. It looks like the path through ReplicationControlManager.handleNodeDeactivated could result in a PartitionChangeRecord which has leaderId set to -1.
There was a problem hiding this comment.
It's true and a partition could have isr and no leader. However, in that case, isrMembers in brokersToIsrs will still be updated with key from replicaId in isr and isr will never have -1 in its list. The noLeader info is only stored in the value of isrMembers.
There was a problem hiding this comment.
I stepped through testNoLeader and it seems that -1 can indeed be a key in isrMembers. The noLeaderIterator makes the expectation explicit.
There was a problem hiding this comment.
Got it. The following comment confirmed this.
/**
* A map of broker IDs to the partitions that the broker is in the ISR for.
* Partitions with no isr members appear in this map under id NO_LEADER.
*/
private final TimelineHashMap<Integer, TimelineHashMap<Uuid, int[]>> isrMembers;
chia7712
left a comment
There was a problem hiding this comment.
+1 to this nice patch. Some trivial comments are left. Please take a look.
| val barId = Uuid.fromString("VlFu5c51ToiNx64wtwkhQw") | ||
| val controller = new MockController.Builder(). | ||
| newInitialTopic("foo", fooId).build() | ||
| controller.setActive(false) |
There was a problem hiding this comment.
this controller is mock so disabling active works well for this test. However, I did not observe the check of control activity in production code. Could you share that with me?
There was a problem hiding this comment.
See QuorumController.QuorumMetaLogListener for the callbacks that make the controller active or inactive.
junrao
left a comment
There was a problem hiding this comment.
@hachikuji : Thanks for the updated PR. LGTM too.
| brokersToIsrs.removeTopicEntryForBroker(topic.id, partition.isr[i]); | ||
| } | ||
| } | ||
| brokersToIsrs.removeTopicEntryForBroker(topic.id, NO_LEADER); |
There was a problem hiding this comment.
Got it. The following comment confirmed this.
/**
* A map of broker IDs to the partitions that the broker is in the ISR for.
* Partitions with no isr members appear in this map under id NO_LEADER.
*/
private final TimelineHashMap<Integer, TimelineHashMap<Uuid, int[]>> isrMembers;
|
Thanks for reviews. I will merge this on behalf of @cmccabe to trunk and 2.8. |
|
@hachikuji this PR breaks the build (this PR was merged after #10253). Could you file a hot-fix? |
This patch enables delete topic support for the new KIP-500 controller. Also fixes the following: - Fix a bug where feature level records were not correctly replayed. - Fix a bug in TimelineHashMap#remove where the wrong type was being returned. Reviewers: Jason Gustafson <jason@confluent.io>, Justine Olshan <jolshan@confluent.io>, Ron Dagostino <rdagostino@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>, Jun Rao <junrao@gmail.com> Co-authored-by: Jason Gustafson <jason@confluent.io>
Enable the new KIP-500 controller to delete topics.
Fix a bug where feature level records were not correctly replayed.
Fix a bug in TimelineHashMap#remove where the wrong type was being
returned.