You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "rreddy-22 (via GitHub)" <gi...@apache.org> on 2024/08/22 22:26:54 UTC

[PR] KAFKA-17277: [1/2] Add version mapping flag to the storage tool and feature command tool [kafka]

rreddy-22 opened a new pull request, #16973:
URL: https://github.com/apache/kafka/pull/16973

   As a part of KIP-1022 the following has been implemented in this patch:
   
   1. A version-mapping command to to look up the corresponding features for a given metadata version. Using the command with no --release-version argument will return the mapping for the latest stable metadata version.
   2. This command has been added to the FeatureCommand Tool and the Storage Tool.
   3. The storage tools parsing method has been made more modular similar to the feature command tool
   


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731850778


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-

Review Comment:
   nit: Did we mean to remove this line?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731959181


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString

Review Comment:
   I got an exception without the props file for certain configs not being present so this is what worked, I'm not sure if there's a better way



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1733173418


##########
tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:
##########
@@ -282,6 +298,32 @@ static void handleDisable(Namespace namespace, Admin adminClient) throws TerseEx
         update("disable", adminClient, updates, namespace.getBoolean("dry_run"));
     }
 
+    static void handleVersionMapping(Namespace namespace) throws TerseException {
+        // Get the release version from the command-line arguments or default to the latest stable version
+        String releaseVersion = Optional.ofNullable(namespace.getString("release_version"))
+            .orElseGet(() -> {
+                String latestVersion = MetadataVersion.latestProduction().version();
+                System.out.println("No release version provided. Defaulting to the latest stable version: " + latestVersion);

Review Comment:
   I guess I'm just wondering if this line is needed. I think it could make it harder to parse the output if it is expecting a certain format.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1733174539


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -134,6 +138,35 @@ object StorageTool extends Logging {
     formatter.run()
   }
 
+  /**
+   * Maps the given release version to the corresponding metadata version
+   * and prints the corresponding features.
+   *
+   * @param namespace       Arguments containing the release version.
+   * @param printStream     The print stream to output the version mapping.
+   */
+  def runVersionMappingCommand(
+    namespace: Namespace,
+    printStream: PrintStream
+  ): Unit = {
+    val releaseVersion = Option(namespace.getString("release_version")).getOrElse(MetadataVersion.LATEST_PRODUCTION.toString)
+    try {
+      val metadataVersion = MetadataVersion.fromVersionString(releaseVersion)
+
+      val metadataVersionLevel = metadataVersion.featureLevel()
+      printStream.printf("metadata.version=%d (%s)  ", metadataVersionLevel, releaseVersion)
+
+      for (feature <- Features.values()) {
+        val featureLevel = feature.defaultValue(metadataVersion)
+        printStream.printf("%s=%d  ", feature.featureName, featureLevel)

Review Comment:
   I know the KIP example wasn't like this, but I wonder if we could put the features all on new lines.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731949965


##########
tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:
##########
@@ -282,6 +298,32 @@ static void handleDisable(Namespace namespace, Admin adminClient) throws TerseEx
         update("disable", adminClient, updates, namespace.getBoolean("dry_run"));
     }
 
+    static void handleVersionMapping(Namespace namespace) throws TerseException {
+        // Get the release version from the command-line arguments or default to the latest stable version
+        String releaseVersion = Optional.ofNullable(namespace.getString("release_version"))
+            .orElseGet(() -> {
+                String latestVersion = MetadataVersion.latestProduction().version();
+                System.out.println("No release version provided. Defaulting to the latest stable version: " + latestVersion);

Review Comment:
   I think so? the describe command uses printf and the update method uses println 



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731939655


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-

Review Comment:
   Yeah I did, usually there isn't a new line after the license stuff right



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1735207580


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -134,6 +138,35 @@ object StorageTool extends Logging {
     formatter.run()
   }
 
+  /**
+   * Maps the given release version to the corresponding metadata version
+   * and prints the corresponding features.
+   *
+   * @param namespace       Arguments containing the release version.
+   * @param printStream     The print stream to output the version mapping.
+   */
+  def runVersionMappingCommand(
+    namespace: Namespace,
+    printStream: PrintStream
+  ): Unit = {
+    val releaseVersion = Option(namespace.getString("release_version")).getOrElse(MetadataVersion.LATEST_PRODUCTION.toString)
+    try {
+      val metadataVersion = MetadataVersion.fromVersionString(releaseVersion)
+
+      val metadataVersionLevel = metadataVersion.featureLevel()
+      printStream.printf("metadata.version=%d (%s)  ", metadataVersionLevel, releaseVersion)
+
+      for (feature <- Features.values()) {
+        val featureLevel = feature.defaultValue(metadataVersion)
+        printStream.printf("%s=%d  ", feature.featureName, featureLevel)

Review Comment:
   yep sure!
   



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan merged PR #16973:
URL: https://github.com/apache/kafka/pull/16973


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731851052


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -153,50 +186,92 @@ object StorageTool extends Logging {
   }
 
   def parseArguments(args: Array[String]): Namespace = {
-    val parser = ArgumentParsers.
-      newArgumentParser("kafka-storage", /* defaultHelp */ true, /* prefixChars */ "-", /* fromFilePrefix */ "@").

Review Comment:
   should we keep the /* */ comments?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1735206926


##########
tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:
##########
@@ -282,6 +298,32 @@ static void handleDisable(Namespace namespace, Admin adminClient) throws TerseEx
         update("disable", adminClient, updates, namespace.getBoolean("dry_run"));
     }
 
+    static void handleVersionMapping(Namespace namespace) throws TerseException {
+        // Get the release version from the command-line arguments or default to the latest stable version
+        String releaseVersion = Optional.ofNullable(namespace.getString("release_version"))
+            .orElseGet(() -> {
+                String latestVersion = MetadataVersion.latestProduction().version();
+                System.out.println("No release version provided. Defaulting to the latest stable version: " + latestVersion);

Review Comment:
   ahhh I get it now! I'll remove it thanks!



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1733161358


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString

Review Comment:
   Hmm... it appears like the uuid command doesn't need it? Is it the case that you could remove line 262 and it would work?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731870150


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString

Review Comment:
   Do we need a properties file for this command?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731944290


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString
+      PropertiesUtils.writePropertiesFile(properties, configPathString, true)
+
+      // Prepare the arguments list
+      val arguments = ListBuffer[String]("version-mapping")
+
+      // Add the release version argument
+      if (releaseVersion != null) {
+        arguments += "--release-version"
+        arguments += releaseVersion
+      }
+
+      arguments += "--config"
+      arguments += configPathString
+
+      // Execute the StorageTool with the arguments
+      StorageTool.execute(arguments.toArray, new PrintStream(stream))
+
+    } finally {
+      Utils.delete(tempDir)
+    }
+  }
+
+  @Test
+  def testVersionMappingWithValidReleaseVersion(): Unit = {
+    val properties = new Properties()
+    properties.putAll(defaultStaticQuorumProperties)
+
+    val stream = new ByteArrayOutputStream()
+    // Test with a valid release version
+    assertEquals(0, runVersionMappingCommand(stream, properties, "3.3-IV3"))
+
+    val output = stream.toString()
+    assertTrue(output.contains("metadata.version=7 (3.3-IV3)"),
+      s"Output did not contain expected Metadata Version: $output")
+    assertTrue(output.contains("kraft.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("test.feature.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("transaction.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+  }
+
+  @Test
+  def testVersionMappingWithNoReleaseVersion(): Unit = {
+    val properties = new Properties()
+    properties.putAll(defaultStaticQuorumProperties)
+
+    val stream = new ByteArrayOutputStream()
+    assertEquals(0, runVersionMappingCommand(stream, properties, null))
+
+    val output = stream.toString
+    assertTrue(output.contains("metadata.version=21 (3.9-IV0)"),

Review Comment:
   yesss thanks for the catch!



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731871226


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString
+      PropertiesUtils.writePropertiesFile(properties, configPathString, true)
+
+      // Prepare the arguments list
+      val arguments = ListBuffer[String]("version-mapping")
+
+      // Add the release version argument
+      if (releaseVersion != null) {
+        arguments += "--release-version"
+        arguments += releaseVersion
+      }
+
+      arguments += "--config"
+      arguments += configPathString
+
+      // Execute the StorageTool with the arguments
+      StorageTool.execute(arguments.toArray, new PrintStream(stream))
+
+    } finally {
+      Utils.delete(tempDir)
+    }
+  }
+
+  @Test
+  def testVersionMappingWithValidReleaseVersion(): Unit = {
+    val properties = new Properties()
+    properties.putAll(defaultStaticQuorumProperties)
+
+    val stream = new ByteArrayOutputStream()
+    // Test with a valid release version
+    assertEquals(0, runVersionMappingCommand(stream, properties, "3.3-IV3"))
+
+    val output = stream.toString()
+    assertTrue(output.contains("metadata.version=7 (3.3-IV3)"),
+      s"Output did not contain expected Metadata Version: $output")
+    assertTrue(output.contains("kraft.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("test.feature.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("transaction.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+  }
+
+  @Test
+  def testVersionMappingWithNoReleaseVersion(): Unit = {
+    val properties = new Properties()
+    properties.putAll(defaultStaticQuorumProperties)
+
+    val stream = new ByteArrayOutputStream()
+    assertEquals(0, runVersionMappingCommand(stream, properties, null))
+
+    val output = stream.toString
+    assertTrue(output.contains("metadata.version=21 (3.9-IV0)"),

Review Comment:
   We probably don't want to hardcode these values. Can we use MetadataVersion.latestProduction and iterate through the Features to find the versions for those?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1733153423


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-

Review Comment:
   I think some files have it and some don't. 



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on PR #16973:
URL: https://github.com/apache/kafka/pull/16973#issuecomment-2313065712

   Can we also check the java 8 build? Seems like compilation failed.


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1739491401


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,95 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Prepare the arguments list
+      val arguments = ListBuffer[String]("version-mapping")
+
+      // Add the release version argument
+      if (releaseVersion != null) {
+        arguments += "--release-version"
+        arguments += releaseVersion
+      }
+
+      // Execute the StorageTool with the arguments
+      StorageTool.execute(arguments.toArray, new PrintStream(stream))
+
+    } finally {
+      Utils.delete(tempDir)
+    }
+  }
+
+  @Test
+  def testVersionMappingWithValidReleaseVersion(): Unit = {
+    val stream = new ByteArrayOutputStream()
+    // Test with a valid release version
+    assertEquals(0, runVersionMappingCommand(stream, "3.3-IV3"))
+
+    val output = stream.toString()
+    assertTrue(output.contains("metadata.version=7 (3.3-IV3)"),

Review Comment:
   small nit: should we iterate through all the features and not hard code them? It shouldn't be too bad since the the values should all be 0.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731939314


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -153,50 +186,92 @@ object StorageTool extends Logging {
   }
 
   def parseArguments(args: Array[String]): Namespace = {
-    val parser = ArgumentParsers.
-      newArgumentParser("kafka-storage", /* defaultHelp */ true, /* prefixChars */ "-", /* fromFilePrefix */ "@").
-      description("The Kafka storage tool.")
+    val parser = ArgumentParsers
+      .newArgumentParser("kafka-storage", true, "-", "@")
+      .description("The Kafka storage tool.")
 
     val subparsers = parser.addSubparsers().dest("command")
 
-    val infoParser = subparsers.addParser("info").
-      help("Get information about the Kafka log directories on this node.")
-    val formatParser = subparsers.addParser("format").
-      help("Format the Kafka log directories on this node.")
-    subparsers.addParser("random-uuid").help("Print a random UUID.")
-    List(infoParser, formatParser).foreach(parser => {
-      parser.addArgument("--config", "-c").
-        action(store()).
-        required(true).
-        help("The Kafka configuration file to use.")
-    })
-    formatParser.addArgument("--cluster-id", "-t").
-      action(store()).
-      required(true).
-      help("The cluster ID to use.")
-    formatParser.addArgument("--add-scram", "-S").
-      action(append()).
-      help("""A SCRAM_CREDENTIAL to add to the __cluster_metadata log e.g.
+    addInfoParser(subparsers)
+    addFormatParser(subparsers)
+    addVersionMappingParser(subparsers)
+    addRandomUuidParser(subparsers)
+
+    parser.parseArgs(args)
+  }
+
+  private def addInfoParser(subparsers: Subparsers): Unit = {
+    val infoParser = subparsers.addParser("info")
+      .help("Get information about the Kafka log directories on this node.")
+
+    addCommonArguments(infoParser)
+  }
+
+  private def addFormatParser(subparsers: Subparsers): Unit = {
+    val formatParser = subparsers.addParser("format")
+      .help("Format the Kafka log directories on this node.")
+
+    formatParser.addArgument("--cluster-id", "-t")
+      .action(store())
+      .required(true)
+      .help("The cluster ID to use.")
+
+    formatParser.addArgument("--add-scram", "-S")
+      .action(append())
+      .help("""A SCRAM_CREDENTIAL to add to the __cluster_metadata log e.g.
               |'SCRAM-SHA-256=[name=alice,password=alice-secret]'
               |'SCRAM-SHA-512=[name=alice,iterations=8192,salt="N3E=",saltedpassword="YCE="]'""".stripMargin)
-    formatParser.addArgument("--ignore-formatted", "-g").
-      action(storeTrue())
-    formatParser.addArgument("--release-version", "-r").
-      action(store()).
-      help(s"The release version to use for the initial feature settings. The minimum is " +
+
+    formatParser.addArgument("--ignore-formatted", "-g")
+      .action(storeTrue())
+
+    formatParser.addArgument("--release-version", "-r")
+      .action(store())
+      .help(s"The release version to use for the initial feature settings. The minimum is " +
         s"${MetadataVersion.IBP_3_0_IV0}; the default is ${MetadataVersion.LATEST_PRODUCTION}")
-    formatParser.addArgument("--feature", "-f").
-      help("The setting to use for a specific feature, in feature=level format. For example: `kraft.version=1`.").
-      action(append())
+
+    formatParser.addArgument("--feature", "-f")
+      .help("The setting to use for a specific feature, in feature=level format. For example: `kraft.version=1`.")
+      .action(append())
+
     val reconfigurableQuorumOptions = formatParser.addMutuallyExclusiveGroup()
-    reconfigurableQuorumOptions.addArgument("--standalone", "-s").
-      help("Used to initialize a single-node quorum controller quorum.").
-      action(storeTrue())
-    reconfigurableQuorumOptions.addArgument("--initial-controllers", "-I").
-      help("The initial controllers, as a comma-separated list of id@hostname:port:directory. The same values must be used to format all nodes. For example:\n" +
-        "0@example.com:8082:JEXY6aqzQY-32P5TStzaFg,1@example.com:8083:MvDxzVmcRsaTz33bUuRU6A,2@example.com:8084:07R5amHmR32VDA6jHkGbTA\n").
-      action(store())
-    parser.parseArgs(args)
+    reconfigurableQuorumOptions.addArgument("--standalone", "-s")
+      .help("Used to initialize a single-node quorum controller quorum.")
+      .action(storeTrue())
+
+    reconfigurableQuorumOptions.addArgument("--initial-controllers", "-I")
+      .help("The initial controllers, as a comma-separated list of id@hostname:port:directory. The same values must be used to format all nodes. For example:\n" +
+        "0@example.com:8082:JEXY6aqzQY-32P5TStzaFg,1@example.com:8083:MvDxzVmcRsaTz33bUuRU6A,2@example.com:8084:07R5amHmR32VDA6jHkGbTA\n")
+      .action(store())
+
+    addCommonArguments(formatParser)
+  }
+
+  private def addVersionMappingParser(subparsers: Subparsers): Unit = {
+    val versionMappingParser = subparsers.addParser("version-mapping")
+      .help("Look up the corresponding features for a given metadata version. " +
+        "Using the command with no  --release-version  argument will return the mapping for " +
+        "the latest stable metadata version"
+      )
+
+    versionMappingParser.addArgument("--release-version", "-r")
+      .action(store())
+      .help(s"The release version to use for the corresponding feature mapping. The minimum is " +
+        s"${MetadataVersion.IBP_3_0_IV0}; the default is ${MetadataVersion.LATEST_PRODUCTION}")
+
+    addCommonArguments(versionMappingParser)
+  }
+
+  private def addRandomUuidParser(subparsers: Subparsers): Unit = {
+    subparsers.addParser("random-uuid")
+      .help("Print a random UUID.")
+  }
+
+  private def addCommonArguments(parser: Subparser): Unit = {

Review Comment:
   ah yes that makes more sense!



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731850276


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -153,50 +186,92 @@ object StorageTool extends Logging {
   }
 
   def parseArguments(args: Array[String]): Namespace = {
-    val parser = ArgumentParsers.
-      newArgumentParser("kafka-storage", /* defaultHelp */ true, /* prefixChars */ "-", /* fromFilePrefix */ "@").
-      description("The Kafka storage tool.")
+    val parser = ArgumentParsers
+      .newArgumentParser("kafka-storage", true, "-", "@")
+      .description("The Kafka storage tool.")
 
     val subparsers = parser.addSubparsers().dest("command")
 
-    val infoParser = subparsers.addParser("info").
-      help("Get information about the Kafka log directories on this node.")
-    val formatParser = subparsers.addParser("format").
-      help("Format the Kafka log directories on this node.")
-    subparsers.addParser("random-uuid").help("Print a random UUID.")
-    List(infoParser, formatParser).foreach(parser => {
-      parser.addArgument("--config", "-c").
-        action(store()).
-        required(true).
-        help("The Kafka configuration file to use.")
-    })
-    formatParser.addArgument("--cluster-id", "-t").
-      action(store()).
-      required(true).
-      help("The cluster ID to use.")
-    formatParser.addArgument("--add-scram", "-S").
-      action(append()).
-      help("""A SCRAM_CREDENTIAL to add to the __cluster_metadata log e.g.
+    addInfoParser(subparsers)
+    addFormatParser(subparsers)
+    addVersionMappingParser(subparsers)
+    addRandomUuidParser(subparsers)
+
+    parser.parseArgs(args)
+  }
+
+  private def addInfoParser(subparsers: Subparsers): Unit = {
+    val infoParser = subparsers.addParser("info")
+      .help("Get information about the Kafka log directories on this node.")
+
+    addCommonArguments(infoParser)
+  }
+
+  private def addFormatParser(subparsers: Subparsers): Unit = {
+    val formatParser = subparsers.addParser("format")
+      .help("Format the Kafka log directories on this node.")
+
+    formatParser.addArgument("--cluster-id", "-t")
+      .action(store())
+      .required(true)
+      .help("The cluster ID to use.")
+
+    formatParser.addArgument("--add-scram", "-S")
+      .action(append())
+      .help("""A SCRAM_CREDENTIAL to add to the __cluster_metadata log e.g.
               |'SCRAM-SHA-256=[name=alice,password=alice-secret]'
               |'SCRAM-SHA-512=[name=alice,iterations=8192,salt="N3E=",saltedpassword="YCE="]'""".stripMargin)
-    formatParser.addArgument("--ignore-formatted", "-g").
-      action(storeTrue())
-    formatParser.addArgument("--release-version", "-r").
-      action(store()).
-      help(s"The release version to use for the initial feature settings. The minimum is " +
+
+    formatParser.addArgument("--ignore-formatted", "-g")
+      .action(storeTrue())
+
+    formatParser.addArgument("--release-version", "-r")
+      .action(store())
+      .help(s"The release version to use for the initial feature settings. The minimum is " +
         s"${MetadataVersion.IBP_3_0_IV0}; the default is ${MetadataVersion.LATEST_PRODUCTION}")
-    formatParser.addArgument("--feature", "-f").
-      help("The setting to use for a specific feature, in feature=level format. For example: `kraft.version=1`.").
-      action(append())
+
+    formatParser.addArgument("--feature", "-f")
+      .help("The setting to use for a specific feature, in feature=level format. For example: `kraft.version=1`.")
+      .action(append())
+
     val reconfigurableQuorumOptions = formatParser.addMutuallyExclusiveGroup()
-    reconfigurableQuorumOptions.addArgument("--standalone", "-s").
-      help("Used to initialize a single-node quorum controller quorum.").
-      action(storeTrue())
-    reconfigurableQuorumOptions.addArgument("--initial-controllers", "-I").
-      help("The initial controllers, as a comma-separated list of id@hostname:port:directory. The same values must be used to format all nodes. For example:\n" +
-        "0@example.com:8082:JEXY6aqzQY-32P5TStzaFg,1@example.com:8083:MvDxzVmcRsaTz33bUuRU6A,2@example.com:8084:07R5amHmR32VDA6jHkGbTA\n").
-      action(store())
-    parser.parseArgs(args)
+    reconfigurableQuorumOptions.addArgument("--standalone", "-s")
+      .help("Used to initialize a single-node quorum controller quorum.")
+      .action(storeTrue())
+
+    reconfigurableQuorumOptions.addArgument("--initial-controllers", "-I")
+      .help("The initial controllers, as a comma-separated list of id@hostname:port:directory. The same values must be used to format all nodes. For example:\n" +
+        "0@example.com:8082:JEXY6aqzQY-32P5TStzaFg,1@example.com:8083:MvDxzVmcRsaTz33bUuRU6A,2@example.com:8084:07R5amHmR32VDA6jHkGbTA\n")
+      .action(store())
+
+    addCommonArguments(formatParser)
+  }
+
+  private def addVersionMappingParser(subparsers: Subparsers): Unit = {
+    val versionMappingParser = subparsers.addParser("version-mapping")
+      .help("Look up the corresponding features for a given metadata version. " +
+        "Using the command with no  --release-version  argument will return the mapping for " +
+        "the latest stable metadata version"
+      )
+
+    versionMappingParser.addArgument("--release-version", "-r")
+      .action(store())
+      .help(s"The release version to use for the corresponding feature mapping. The minimum is " +
+        s"${MetadataVersion.IBP_3_0_IV0}; the default is ${MetadataVersion.LATEST_PRODUCTION}")
+
+    addCommonArguments(versionMappingParser)
+  }
+
+  private def addRandomUuidParser(subparsers: Subparsers): Unit = {
+    subparsers.addParser("random-uuid")
+      .help("Print a random UUID.")
+  }
+
+  private def addCommonArguments(parser: Subparser): Unit = {

Review Comment:
   Maybe we can call this addConfigArguments?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731885489


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString
+      PropertiesUtils.writePropertiesFile(properties, configPathString, true)
+
+      // Prepare the arguments list
+      val arguments = ListBuffer[String]("version-mapping")
+
+      // Add the release version argument
+      if (releaseVersion != null) {
+        arguments += "--release-version"
+        arguments += releaseVersion
+      }
+
+      arguments += "--config"
+      arguments += configPathString
+
+      // Execute the StorageTool with the arguments
+      StorageTool.execute(arguments.toArray, new PrintStream(stream))
+
+    } finally {
+      Utils.delete(tempDir)
+    }
+  }
+
+  @Test
+  def testVersionMappingWithValidReleaseVersion(): Unit = {
+    val properties = new Properties()
+    properties.putAll(defaultStaticQuorumProperties)
+
+    val stream = new ByteArrayOutputStream()
+    // Test with a valid release version
+    assertEquals(0, runVersionMappingCommand(stream, properties, "3.3-IV3"))
+
+    val output = stream.toString()
+    assertTrue(output.contains("metadata.version=7 (3.3-IV3)"),
+      s"Output did not contain expected Metadata Version: $output")
+    assertTrue(output.contains("kraft.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("test.feature.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("transaction.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+  }
+
+  @Test
+  def testVersionMappingWithNoReleaseVersion(): Unit = {
+    val properties = new Properties()
+    properties.putAll(defaultStaticQuorumProperties)
+
+    val stream = new ByteArrayOutputStream()
+    assertEquals(0, runVersionMappingCommand(stream, properties, null))
+
+    val output = stream.toString
+    assertTrue(output.contains("metadata.version=21 (3.9-IV0)"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("kraft.version=1"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("test.feature.version=1"),
+      s"Output did not contain expected feature mapping: $output")
+    assertTrue(output.contains("transaction.version=0"),
+      s"Output did not contain expected feature mapping: $output")
+  }
+
+  @Test
+  def testVersionMappingWithInvalidReleaseVersion(): Unit = {

Review Comment:
   Can we have a test case for a completely malformed argument? like "abc" or something that isn't even a valid MV?



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1731882824


##########
tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java:
##########
@@ -282,6 +298,32 @@ static void handleDisable(Namespace namespace, Admin adminClient) throws TerseEx
         update("disable", adminClient, updates, namespace.getBoolean("dry_run"));
     }
 
+    static void handleVersionMapping(Namespace namespace) throws TerseException {
+        // Get the release version from the command-line arguments or default to the latest stable version
+        String releaseVersion = Optional.ofNullable(namespace.getString("release_version"))
+            .orElseGet(() -> {
+                String latestVersion = MetadataVersion.latestProduction().version();
+                System.out.println("No release version provided. Defaulting to the latest stable version: " + latestVersion);

Review Comment:
   Does this tool typically print System.out like this? I think it makes sense for the output, but maybe it is enough to just show the version being used as you do on line 314



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1733215746


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -153,50 +186,92 @@ object StorageTool extends Logging {
   }
 
   def parseArguments(args: Array[String]): Namespace = {
-    val parser = ArgumentParsers.
-      newArgumentParser("kafka-storage", /* defaultHelp */ true, /* prefixChars */ "-", /* fromFilePrefix */ "@").
-      description("The Kafka storage tool.")
+    val parser = ArgumentParsers
+      .newArgumentParser("kafka-storage", true, "-", "@")
+      .description("The Kafka storage tool.")
 
     val subparsers = parser.addSubparsers().dest("command")
 
-    val infoParser = subparsers.addParser("info").
-      help("Get information about the Kafka log directories on this node.")
-    val formatParser = subparsers.addParser("format").
-      help("Format the Kafka log directories on this node.")
-    subparsers.addParser("random-uuid").help("Print a random UUID.")
-    List(infoParser, formatParser).foreach(parser => {
-      parser.addArgument("--config", "-c").
-        action(store()).
-        required(true).
-        help("The Kafka configuration file to use.")
-    })
-    formatParser.addArgument("--cluster-id", "-t").
-      action(store()).
-      required(true).
-      help("The cluster ID to use.")
-    formatParser.addArgument("--add-scram", "-S").
-      action(append()).
-      help("""A SCRAM_CREDENTIAL to add to the __cluster_metadata log e.g.
+    addInfoParser(subparsers)
+    addFormatParser(subparsers)
+    addVersionMappingParser(subparsers)
+    addRandomUuidParser(subparsers)
+
+    parser.parseArgs(args)
+  }
+
+  private def addInfoParser(subparsers: Subparsers): Unit = {
+    val infoParser = subparsers.addParser("info")
+      .help("Get information about the Kafka log directories on this node.")
+
+    addCommonArguments(infoParser)
+  }
+
+  private def addFormatParser(subparsers: Subparsers): Unit = {
+    val formatParser = subparsers.addParser("format")
+      .help("Format the Kafka log directories on this node.")
+
+    formatParser.addArgument("--cluster-id", "-t")
+      .action(store())
+      .required(true)
+      .help("The cluster ID to use.")
+
+    formatParser.addArgument("--add-scram", "-S")
+      .action(append())
+      .help("""A SCRAM_CREDENTIAL to add to the __cluster_metadata log e.g.
               |'SCRAM-SHA-256=[name=alice,password=alice-secret]'
               |'SCRAM-SHA-512=[name=alice,iterations=8192,salt="N3E=",saltedpassword="YCE="]'""".stripMargin)
-    formatParser.addArgument("--ignore-formatted", "-g").
-      action(storeTrue())
-    formatParser.addArgument("--release-version", "-r").
-      action(store()).
-      help(s"The release version to use for the initial feature settings. The minimum is " +
+
+    formatParser.addArgument("--ignore-formatted", "-g")
+      .action(storeTrue())
+
+    formatParser.addArgument("--release-version", "-r")
+      .action(store())
+      .help(s"The release version to use for the initial feature settings. The minimum is " +
         s"${MetadataVersion.IBP_3_0_IV0}; the default is ${MetadataVersion.LATEST_PRODUCTION}")
-    formatParser.addArgument("--feature", "-f").
-      help("The setting to use for a specific feature, in feature=level format. For example: `kraft.version=1`.").
-      action(append())
+
+    formatParser.addArgument("--feature", "-f")
+      .help("The setting to use for a specific feature, in feature=level format. For example: `kraft.version=1`.")
+      .action(append())
+
     val reconfigurableQuorumOptions = formatParser.addMutuallyExclusiveGroup()
-    reconfigurableQuorumOptions.addArgument("--standalone", "-s").
-      help("Used to initialize a single-node quorum controller quorum.").
-      action(storeTrue())
-    reconfigurableQuorumOptions.addArgument("--initial-controllers", "-I").
-      help("The initial controllers, as a comma-separated list of id@hostname:port:directory. The same values must be used to format all nodes. For example:\n" +
-        "0@example.com:8082:JEXY6aqzQY-32P5TStzaFg,1@example.com:8083:MvDxzVmcRsaTz33bUuRU6A,2@example.com:8084:07R5amHmR32VDA6jHkGbTA\n").
-      action(store())
-    parser.parseArgs(args)
+    reconfigurableQuorumOptions.addArgument("--standalone", "-s")
+      .help("Used to initialize a single-node quorum controller quorum.")
+      .action(storeTrue())
+
+    reconfigurableQuorumOptions.addArgument("--initial-controllers", "-I")
+      .help("The initial controllers, as a comma-separated list of id@hostname:port:directory. The same values must be used to format all nodes. For example:\n" +
+        "0@example.com:8082:JEXY6aqzQY-32P5TStzaFg,1@example.com:8083:MvDxzVmcRsaTz33bUuRU6A,2@example.com:8084:07R5amHmR32VDA6jHkGbTA\n")
+      .action(store())
+
+    addCommonArguments(formatParser)
+  }
+
+  private def addVersionMappingParser(subparsers: Subparsers): Unit = {
+    val versionMappingParser = subparsers.addParser("version-mapping")
+      .help("Look up the corresponding features for a given metadata version. " +
+        "Using the command with no  --release-version  argument will return the mapping for " +

Review Comment:
   nit: I think there are extra spaces before and after the `--release-version` same with the feature command tool



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1733212040


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -153,50 +186,92 @@ object StorageTool extends Logging {
   }
 
   def parseArguments(args: Array[String]): Namespace = {
-    val parser = ArgumentParsers.
-      newArgumentParser("kafka-storage", /* defaultHelp */ true, /* prefixChars */ "-", /* fromFilePrefix */ "@").
-      description("The Kafka storage tool.")
+    val parser = ArgumentParsers
+      .newArgumentParser("kafka-storage", true, "-", "@")
+      .description("The Kafka storage tool.")
 
     val subparsers = parser.addSubparsers().dest("command")
 
-    val infoParser = subparsers.addParser("info").
-      help("Get information about the Kafka log directories on this node.")
-    val formatParser = subparsers.addParser("format").
-      help("Format the Kafka log directories on this node.")
-    subparsers.addParser("random-uuid").help("Print a random UUID.")
-    List(infoParser, formatParser).foreach(parser => {

Review Comment:
   Maybe not a huge deal, but I believe we reordered the parsers for formatParser. I think we can just call the commonArguments/Config parser method first.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17277: [1/2] Add version mapping command to the storage tool and feature command tool [kafka]

Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #16973:
URL: https://github.com/apache/kafka/pull/16973#discussion_r1735265785


##########
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##########
@@ -433,5 +433,91 @@ Found problem:
       contains("Formatting dynamic metadata voter directory %s".format(availableDirs.head)),
       "Failed to find content in output: " + stream.toString())
   }
-}
 
+  private def runVersionMappingCommand(
+    stream: ByteArrayOutputStream,
+    properties: Properties,
+    releaseVersion: String
+  ): Int = {
+    val tempDir = TestUtils.tempDir()
+    try {
+      // Write the properties to a temporary file
+      val configPathString = new File(tempDir.getAbsolutePath, "version-mapping.props").toString

Review Comment:
   Ah yes my bad I didn't realize I added the config arg method for the version mapping parser when I was making the code modular, thanks for the catch! Updated the tests as well



-- 
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-unsubscribe@kafka.apache.org

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