mumrah commented on code in PR #13799:
URL: https://github.com/apache/kafka/pull/13799#discussion_r1214563481
##########
metadata/src/main/java/org/apache/kafka/controller/errors/ControllerExceptions.java:
##########
@@ -38,4 +47,104 @@ public static boolean isTimeoutException(Throwable
exception) {
if (!(exception instanceof TimeoutException)) return false;
return true;
}
+
+ /**
+ * Check if an exception is a NotController exception.
+ *
+ * @param exception The exception to check.
+ * @return True if the exception is a NotController exception.
+ */
+ public static boolean isNotControllerException(Throwable exception) {
+ if (exception == null) return false;
+ if (exception instanceof ExecutionException) {
+ exception = exception.getCause();
+ if (exception == null) return false;
+ }
+ if (!(exception instanceof NotControllerException)) return false;
+ return true;
+ }
+
+ /**
+ * Create a new exception indicating that the controller is in
pre-migration mode, so the
+ * operation cannot be completed.
+ *
+ * @param latestController The current controller.
+ * @return The new NotControllerException.
+ */
+ public static NotControllerException newPreMigrationException(OptionalInt
latestController) {
Review Comment:
I'm guessing the argument here is the controller ID? Can you rename it to
reflect that? (same for other methods in this class)
##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -2024,13 +2029,8 @@ public CompletableFuture<ElectLeadersResponseData>
electLeaders(
public CompletableFuture<FinalizedControllerFeatures> finalizedFeatures(
ControllerRequestContext context
) {
- // It's possible that we call ApiVersionRequest before consuming the
log since ApiVersionRequest is sent when
- // initialize NetworkClient, we should not return an error since it
would stop the NetworkClient from working correctly.
- if (lastCommittedOffset == -1) {
Review Comment:
Was this a bug previously? If another node sent an ApiVersionRequest prior
to loading the log, we would have not returned any MetadataVersion (whereas
with this patch, we would).
--
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]