cmccabe commented on code in PR #12715: URL: https://github.com/apache/kafka/pull/12715#discussion_r991455745
########## metadata/src/main/java/org/apache/kafka/image/ImageWriterOptions.java: ########## @@ -0,0 +1,80 @@ +/* + * 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 org.apache.kafka.image; + +import org.apache.kafka.server.common.MetadataVersion; + +import java.util.function.Consumer; + + +/** + * The options to use when writing an image. + */ +public final class ImageWriterOptions { + public static class Builder { + private MetadataVersion metadataVersion = MetadataVersion.latest(); + private Consumer<UnwritableMetadataException> lossHandler = e -> { + throw e; + }; + + public Builder setMetadataVersion(MetadataVersion metadataVersion) { + if (metadataVersion.isLessThan(MetadataVersion.MINIMUM_BOOTSTRAP_VERSION)) { + // When writing an image, all versions less than 3.3-IV0 are treated as 3.0-IV1. + // This is because those versions don't support FeatureLevelRecord. + setRawMetadataVersion(MetadataVersion.MINIMUM_KRAFT_VERSION); Review Comment: > First, it looks like the controller only writes the metadata version to the log if it is greater than the minimum bootstrap version greater *or equal* > so this should never be true, right? It will never be true if the metadata version is less than 3.3-IV0. Otherwise it will become true when we write that record > Second, does this mean that the user cannot incrementally enable features introduced between version 3.0 and 3.3. They have to set the version to 3.3. Yes. We goofed. `FeatureLevelRecord` should have been introduced much earlier than it was. But we can't fix the past. > It doesn't look like the controller checks this when accepting metadata version updates. In other words it looks like the use can set the version 3.2 but it won't have an effect on the metadata version of the cluster. Is this accurate? No. The controller does not allow setting any metadata.version that is less than 3.3-IV0 Those old versions are supported for the purpose of rolling upgrade only. You can't create a new cluster with them (through normal means) and you can't downgrade to them. -- 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]
