soarez commented on code in PR #15834:
URL: https://github.com/apache/kafka/pull/15834#discussion_r1628002868


##########
core/src/main/java/kafka/server/MetadataVersionConfigValidator.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package kafka.server;
+
+import org.apache.kafka.image.MetadataDelta;
+import org.apache.kafka.image.MetadataImage;
+import org.apache.kafka.image.loader.LoaderManifest;
+import org.apache.kafka.image.publisher.MetadataPublisher;
+import org.apache.kafka.server.common.MetadataVersion;
+import org.apache.kafka.server.fault.FaultHandler;
+
+public class MetadataVersionConfigValidator implements MetadataPublisher {

Review Comment:
   I'm glad you asked.
   
   There are two ways the broker can assume a MetadataVersion:
   
   1. Via the `inter.broker.protocol.version` configuration property in ZK mode
   2. Via discovering a `FeatureRecord` for `metadata.version` in the cluster 
metadata in KRaft mode. This is preset with `--release-version` in the format 
command or with `kafka-features.sh upgrade --metadata`.
   
   For (1) we have the version set at startup time, and we can catch the 
conifguration error in `KafkaConfig` as the properties are loaded. But for (2) 
we can only validate config later when the version is discovered from metadata.
   
   Ealier in this PR I had the check in `BrokerMetadataPublisher` — this class 
streams metadata records in the broker and distributes them to various types of 
`MetadataPublisher` for reconciliation — but instaed of adding the check to 
that class I think it's better reuse the publisher pattern, similar to how the 
broker registration re-sending was extracted to `BrokerRegistrationTracker` in 
#15945.
   
   Perhaps we could implement `MetadataPublisher` directly in `KafkaConfig`, 
but I thought that class is big enough already.
   
   Let me know what you think.
   



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to