brandboat commented on code in PR #22531:
URL: https://github.com/apache/kafka/pull/22531#discussion_r4056153349
##########
tools/src/test/java/org/apache/kafka/tools/MetadataQuorumCommandTest.java:
##########
@@ -194,4 +198,60 @@ private static void assertHumanReadable(String output) {
assertTrue(lastCaughtUpTimestamp.contains("ms ago"));
assertTrue(lastCaughtUpTimestampValue.matches("\\d*"));
}
+
+ /**
+ * Verify that add-controller and remove-controller work using only the
+ * controller node ID (no directory ID or endpoints required from the
user).
+ */
+ @ClusterTest(types = {Type.KRAFT}, controllers = 2, standalone = true)
+ public void testAddAndRemoveControllerByIdSuccessful(ClusterInstance
cluster) throws Exception {
Review Comment:
@showuon, I checked the behavior for directory ID and endpoint mismatches.
For a directory ID mismatch:
- If the controller endpoint is correct but the directory ID is wrong, the
request is treated as “lagging behind.” This is because a ReplicaKey is
composed of `controllerId + directoryId`. The real observer has fetched using
its actual directory ID, but the request uses a different directory ID. Since
the leader has no fetch/catch-up state for that exact ReplicaKey, Kafka treats
it as a different replica that has not caught up yet.
For an endpoint mismatch, it's a bit tricky:
- If the endpoint is completely wrong or unreachable, AddVoterHandler sends
an `API_VERSIONS` request to that endpoint, the request fails, and AddVoter
fails.
- If the endpoint is reachable but points to another controller, AddVoter
may still succeed. The endpoint is used for the API_VERSIONS probe, while voter
catch-up is checked by ReplicaKey, not by endpoint ownership. This can be
self-healing. After the target controller becomes a voter, KafkaRaftClient can
detect that its local endpoint does not match the latest voter set and send
UpdateVoter. The leader can then persist a corrected VotersRecord. This
endpoint update mechanism is part of [KIP-853’s UpdateVoter
flow](https://cwiki.apache.org/confluence/spaces/KAFKA/pages/217391519/KIP-853%2BKRaft%2BController%2BMembership%2BChanges).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]