You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2025/10/09 12:58:16 UTC

[PR] KAFKA-18786: add nodeId to DescribeFeaturesOptions [kafka]

FrankYang0529 opened a new pull request, #20674:
URL: https://github.com/apache/kafka/pull/20674

   Support `kafka-features.sh` to describe features from a specific node.
   
   * Add `nodeId` to `DescribeFeaturesOptions`.
   * Add `--node-id` to `kafka-features.sh --describe`.
   
   KIP: https://cwiki.apache.org/confluence/x/5gnXF


-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeFeaturesTest.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.clients.admin;
+
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.server.common.EligibleLeaderReplicasVersion;
+import org.apache.kafka.server.common.Feature;
+import org.apache.kafka.server.common.GroupVersion;
+import org.apache.kafka.server.common.KRaftVersion;
+import org.apache.kafka.server.common.MetadataVersion;
+import org.apache.kafka.server.common.ShareVersion;
+import org.apache.kafka.server.common.StreamsVersion;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class DescribeFeaturesTest {
+
+    @ClusterTest(
+        types = {Type.KRAFT},
+        metadataVersion = MetadataVersion.IBP_3_7_IV0,
+        controllers = 2,
+        brokers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(
+                id = 3000,
+                key = "unstable.api.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 3001,
+                key = "unstable.api.versions.enable",
+                value = "false"
+                ),
+            @ClusterConfigProperty(
+                id = 0,
+                key = "unstable.feature.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 1,
+                key = "unstable.feature.versions.enable",
+                value = "false"
+                )
+        }
+    )
+    public void testUnstableApiVersions(ClusterInstance clusterInstance) {
+        // Test unstable.api.versions.enable on controller nodes
+        try (Admin admin = clusterInstance.admin(Map.of(), true)) {
+            // unstable.api.versions.enable is true on node 3000
+            assertFeatures(admin, 3000, true);
+
+            // unstable.api.versions.enable is false on node 3001
+            assertFeatures(admin, 3001, false);
+        }
+
+        // Test unstable.feature.versions.enable on broker nodes
+        try (Admin admin = clusterInstance.admin()) {
+            // unstable.feature.versions.enable is true on node 0
+            assertFeatures(admin, 0, true);
+
+            // unstable.feature.versions.enable is false on node 1
+            assertFeatures(admin, 1, false);
+        }
+    }
+
+    @ClusterTest(types = {Type.KRAFT})
+    public void testSendRequestToWrongNodeType(ClusterInstance clusterInstance) {
+        try (Admin admin = clusterInstance.admin()) {
+            // use bootstrap-servers to send request to controller
+            assertThrows(
+                ExecutionException.class,
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(3000).timeoutMs(1000)).featureMetadata().get());
+        }
+
+        try (Admin admin = clusterInstance.admin(Map.of(), true)) {
+            // use bootstrap-controllers to send request to broker
+            assertThrows(
+                ExecutionException.class,
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(0).timeoutMs(1000)).featureMetadata().get());
+        }
+    }
+
+    private void assertFeatures(Admin admin, int nodeId, boolean unstable) {
+        FeatureMetadata featureMetadata = assertDoesNotThrow(
+            () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(nodeId)).featureMetadata().get());
+        if (unstable) {
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange(Feature.GROUP_VERSION.minimumProduction(), Feature.GROUP_VERSION.latestTesting()),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange(Feature.KRAFT_VERSION.minimumProduction(), Feature.KRAFT_VERSION.latestTesting()),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.MINIMUM_VERSION.featureLevel(), MetadataVersion.latestTesting().featureLevel()),
+                ShareVersion.FEATURE_NAME, new SupportedVersionRange(Feature.SHARE_VERSION.minimumProduction(), Feature.SHARE_VERSION.latestTesting()),
+                StreamsVersion.FEATURE_NAME, new SupportedVersionRange(Feature.STREAMS_VERSION.minimumProduction(), Feature.STREAMS_VERSION.latestTesting()),
+                TransactionVersion.FEATURE_NAME, new SupportedVersionRange(Feature.TRANSACTION_VERSION.minimumProduction(), Feature.TRANSACTION_VERSION.latestTesting()),
+                EligibleLeaderReplicasVersion.FEATURE_NAME, new SupportedVersionRange(Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.minimumProduction(), Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.latestTesting())
+            ), featureMetadata.supportedFeatures());
+        } else {
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange(Feature.GROUP_VERSION.minimumProduction(), Feature.GROUP_VERSION.latestProduction()),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange(Feature.KRAFT_VERSION.minimumProduction(), Feature.KRAFT_VERSION.latestProduction()),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.MINIMUM_VERSION.featureLevel(), MetadataVersion.latestProduction().featureLevel()),
+                ShareVersion.FEATURE_NAME, new SupportedVersionRange(Feature.SHARE_VERSION.minimumProduction(), Feature.SHARE_VERSION.latestProduction()),
+                StreamsVersion.FEATURE_NAME, new SupportedVersionRange(Feature.STREAMS_VERSION.minimumProduction(), Feature.STREAMS_VERSION.latestProduction()),
+                TransactionVersion.FEATURE_NAME, new SupportedVersionRange(Feature.TRANSACTION_VERSION.minimumProduction(), Feature.TRANSACTION_VERSION.latestProduction()),
+                EligibleLeaderReplicasVersion.FEATURE_NAME, new SupportedVersionRange(Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.minimumProduction(), Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.latestProduction())
+            ), featureMetadata.supportedFeatures());

Review Comment:
   Added assertion for `finalizedFeatures`. 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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/DescribeFeaturesOptions.java:
##########
@@ -16,8 +16,27 @@
  */
 package org.apache.kafka.clients.admin;
 
+import java.util.OptionalInt;
+
 /**
  * Options for {@link AdminClient#describeFeatures(DescribeFeaturesOptions)}.
  */
 public class DescribeFeaturesOptions extends AbstractOptions<DescribeFeaturesOptions> {
+    private OptionalInt nodeId = OptionalInt.empty();
+
+    /**
+     * Set the node id to which the request should be sent.
+     */

Review Comment:
   Sorry, I does not describe accurately.
   It should be said that a bootstrap controller can only retrieve the controller’s feature version,
   and a bootstrap broker can only retrieve the broker’s feature version.
   If you try to retrieve the broker’s feature version using a bootstrap controller, it will simply wait until timeout.



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/DescribeFeaturesOptions.java:
##########
@@ -16,8 +16,27 @@
  */
 package org.apache.kafka.clients.admin;
 
+import java.util.OptionalInt;
+
 /**
  * Options for {@link AdminClient#describeFeatures(DescribeFeaturesOptions)}.
  */
 public class DescribeFeaturesOptions extends AbstractOptions<DescribeFeaturesOptions> {
+    private OptionalInt nodeId = OptionalInt.empty();
+
+    /**
+     * Set the node id to which the request should be sent.
+     */

Review Comment:
   Sorry, I does not describe accurately.
   
   It should be said that a bootstrap controller can only retrieve the controller’s feature version,
   and a bootstrap broker can only retrieve the broker’s feature version.
   If you try to retrieve the broker’s feature version using a bootstrap controller, it will simply wait until timeout.



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeFeaturesTest.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.clients.admin;
+
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.server.common.EligibleLeaderReplicasVersion;
+import org.apache.kafka.server.common.Feature;
+import org.apache.kafka.server.common.GroupVersion;
+import org.apache.kafka.server.common.KRaftVersion;
+import org.apache.kafka.server.common.MetadataVersion;
+import org.apache.kafka.server.common.ShareVersion;
+import org.apache.kafka.server.common.StreamsVersion;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class DescribeFeaturesTest {
+
+    @ClusterTest(
+        types = {Type.KRAFT},
+        metadataVersion = MetadataVersion.IBP_3_7_IV0,
+        controllers = 2,
+        brokers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(
+                id = 3000,
+                key = "unstable.api.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 3001,
+                key = "unstable.api.versions.enable",
+                value = "false"
+                ),
+            @ClusterConfigProperty(
+                id = 0,
+                key = "unstable.feature.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 1,
+                key = "unstable.feature.versions.enable",
+                value = "false"
+                )
+        }
+    )
+    public void testUnstableApiVersions(ClusterInstance clusterInstance) {
+        // Test unstable.api.versions.enable on controller nodes
+        try (Admin admin = clusterInstance.admin(Map.of(), true)) {
+            // unstable.api.versions.enable is true on node 3000
+            assertFeatures(admin, 3000, true);
+
+            // unstable.api.versions.enable is false on node 3001
+            assertFeatures(admin, 3001, false);
+        }
+
+        // Test unstable.feature.versions.enable on broker nodes
+        try (Admin admin = clusterInstance.admin()) {
+            // unstable.feature.versions.enable is true on node 0
+            assertFeatures(admin, 0, true);
+
+            // unstable.feature.versions.enable is false on node 1
+            assertFeatures(admin, 1, false);
+        }
+    }
+
+    @ClusterTest(types = {Type.KRAFT})
+    public void testSendRequestToWrongNodeType(ClusterInstance clusterInstance) {
+        try (Admin admin = clusterInstance.admin()) {
+            // use bootstrap-servers to send request to controller
+            assertThrows(
+                ExecutionException.class,
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(3000).timeoutMs(1000)).featureMetadata().get());
+        }
+
+        try (Admin admin = clusterInstance.admin(Map.of(), true)) {
+            // use bootstrap-controllers to send request to broker
+            assertThrows(
+                ExecutionException.class,
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(0).timeoutMs(1000)).featureMetadata().get());
+        }
+    }
+
+    private void assertFeatures(Admin admin, int nodeId, boolean unstable) {
+        FeatureMetadata featureMetadata = assertDoesNotThrow(
+            () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(nodeId)).featureMetadata().get());
+        if (unstable) {
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange(Feature.GROUP_VERSION.minimumProduction(), Feature.GROUP_VERSION.latestTesting()),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange(Feature.KRAFT_VERSION.minimumProduction(), Feature.KRAFT_VERSION.latestTesting()),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.MINIMUM_VERSION.featureLevel(), MetadataVersion.latestTesting().featureLevel()),
+                ShareVersion.FEATURE_NAME, new SupportedVersionRange(Feature.SHARE_VERSION.minimumProduction(), Feature.SHARE_VERSION.latestTesting()),
+                StreamsVersion.FEATURE_NAME, new SupportedVersionRange(Feature.STREAMS_VERSION.minimumProduction(), Feature.STREAMS_VERSION.latestTesting()),
+                TransactionVersion.FEATURE_NAME, new SupportedVersionRange(Feature.TRANSACTION_VERSION.minimumProduction(), Feature.TRANSACTION_VERSION.latestTesting()),
+                EligibleLeaderReplicasVersion.FEATURE_NAME, new SupportedVersionRange(Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.minimumProduction(), Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.latestTesting())
+            ), featureMetadata.supportedFeatures());
+        } else {
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange(Feature.GROUP_VERSION.minimumProduction(), Feature.GROUP_VERSION.latestProduction()),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange(Feature.KRAFT_VERSION.minimumProduction(), Feature.KRAFT_VERSION.latestProduction()),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.MINIMUM_VERSION.featureLevel(), MetadataVersion.latestProduction().featureLevel()),
+                ShareVersion.FEATURE_NAME, new SupportedVersionRange(Feature.SHARE_VERSION.minimumProduction(), Feature.SHARE_VERSION.latestProduction()),
+                StreamsVersion.FEATURE_NAME, new SupportedVersionRange(Feature.STREAMS_VERSION.minimumProduction(), Feature.STREAMS_VERSION.latestProduction()),
+                TransactionVersion.FEATURE_NAME, new SupportedVersionRange(Feature.TRANSACTION_VERSION.minimumProduction(), Feature.TRANSACTION_VERSION.latestProduction()),
+                EligibleLeaderReplicasVersion.FEATURE_NAME, new SupportedVersionRange(Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.minimumProduction(), Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.latestProduction())
+            ), featureMetadata.supportedFeatures());

Review Comment:
   Could you also verify `finalizedFeatures` 



##########
docs/upgrade.html:
##########
@@ -228,6 +228,10 @@ <h5><a id="upgrade_420_notable" href="#upgrade_420_notable">Notable changes in 4
         It is now possible to specify the start time for a Kafka Streams punctuation, instead of relying on the non-deterministic time when you register it.
         For further details, please refer to <a href="https://cwiki.apache.org/confluence/x/9QqWF">KIP-1146</a>.
     </li>
+    <li>
+        Added an optional <code>--node-id</code> flag to the <code>FeatureCommand</code> command. It specifies the node to describe.
+        If not provided, an arbitrary node is used."

Review Comment:
   the `"` is unnecessary, 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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/DescribeFeaturesOptions.java:
##########
@@ -16,8 +16,27 @@
  */
 package org.apache.kafka.clients.admin;
 
+import java.util.OptionalInt;
+
 /**
  * Options for {@link AdminClient#describeFeatures(DescribeFeaturesOptions)}.
  */
 public class DescribeFeaturesOptions extends AbstractOptions<DescribeFeaturesOptions> {
+    private OptionalInt nodeId = OptionalInt.empty();
+
+    /**
+     * Set the node id to which the request should be sent.
+     */

Review Comment:
   Could you add a note to point out --bootstrap-controller only can send to controller and --bootstrap-broker only can send to broker?
   
   I think user maybe need to know this limitation.
   Or it is a common sense for Kraft mode?



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -4519,8 +4519,10 @@ private static byte[] getSaltedPassword(ScramMechanism publicScramMechanism, byt
     public DescribeFeaturesResult describeFeatures(final DescribeFeaturesOptions options) {
         final KafkaFutureImpl<FeatureMetadata> future = new KafkaFutureImpl<>();
         final long now = time.milliseconds();
+        final NodeProvider nodeProvider = options.nodeId().isPresent() ?
+            new ConstantNodeIdProvider(options.nodeId().getAsInt(), true) : new LeastLoadedBrokerOrActiveKController();

Review Comment:
   Could you please add integration tests ?



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -4518,8 +4518,10 @@ private static byte[] getSaltedPassword(ScramMechanism publicScramMechanism, byt
     public DescribeFeaturesResult describeFeatures(final DescribeFeaturesOptions options) {
         final KafkaFutureImpl<FeatureMetadata> future = new KafkaFutureImpl<>();
         final long now = time.milliseconds();
+        final NodeProvider nodeProvider = options.nodeId().isPresent() ?
+            new ConstantNodeIdProvider(options.nodeId().getAsInt(), metadataManager.usingBootstrapControllers()) : new LeastLoadedBrokerOrActiveKController();

Review Comment:
   Thanks for the review. Yes, this API supports bootstrap controller. Updated it.



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeFeaturesTest.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.clients.admin;
+
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.server.common.EligibleLeaderReplicasVersion;
+import org.apache.kafka.server.common.GroupVersion;
+import org.apache.kafka.server.common.KRaftVersion;
+import org.apache.kafka.server.common.MetadataVersion;
+import org.apache.kafka.server.common.ShareVersion;
+import org.apache.kafka.server.common.StreamsVersion;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class DescribeFeaturesTest {
+
+    @ClusterTest(
+        types = {Type.KRAFT},
+        metadataVersion = MetadataVersion.IBP_3_7_IV0,
+        controllers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(
+                id = 3000,
+                key = "unstable.api.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 3001,
+                key = "unstable.api.versions.enable",
+                value = "false"
+                )
+        }
+    )
+    public void testUnstableApiVersions(ClusterInstance clusterInstance) {

Review Comment:
   Could you also add test for broker? 



##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeFeaturesTest.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.clients.admin;
+
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.server.common.EligibleLeaderReplicasVersion;
+import org.apache.kafka.server.common.GroupVersion;
+import org.apache.kafka.server.common.KRaftVersion;
+import org.apache.kafka.server.common.MetadataVersion;
+import org.apache.kafka.server.common.ShareVersion;
+import org.apache.kafka.server.common.StreamsVersion;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class DescribeFeaturesTest {
+
+    @ClusterTest(
+        types = {Type.KRAFT},
+        metadataVersion = MetadataVersion.IBP_3_7_IV0,
+        controllers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(
+                id = 3000,
+                key = "unstable.api.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 3001,
+                key = "unstable.api.versions.enable",
+                value = "false"
+                )
+        }
+    )
+    public void testUnstableApiVersions(ClusterInstance clusterInstance) {
+        try (Admin admin = clusterInstance.admin(Map.of(), true)) {
+            // unstable.api.versions.enable is true on node 3000
+            FeatureMetadata featureMetadata = assertDoesNotThrow(
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(3000)).featureMetadata().get());
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange((short) 0, (short) 1),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange((short) 0, (short) 1),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.IBP_3_3_IV3.featureLevel(), MetadataVersion.IBP_4_2_IV1.featureLevel()),

Review Comment:
   `IBP_4_2_IV1` is not the latest version now.



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
docs/upgrade.html:
##########
@@ -228,6 +228,10 @@ <h5><a id="upgrade_420_notable" href="#upgrade_420_notable">Notable changes in 4
         It is now possible to specify the start time for a Kafka Streams punctuation, instead of relying on the non-deterministic time when you register it.
         For further details, please refer to <a href="https://cwiki.apache.org/confluence/x/9QqWF">KIP-1146</a>.
     </li>
+    <li>
+        Added an optional <code>--node-id</code> flag to the <code>FeatureCommand</code> command. It specifies the node to describe.
+        If not provided, an arbitrary node is used."

Review Comment:
   Yes, removed it.



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -4518,8 +4518,10 @@ private static byte[] getSaltedPassword(ScramMechanism publicScramMechanism, byt
     public DescribeFeaturesResult describeFeatures(final DescribeFeaturesOptions options) {
         final KafkaFutureImpl<FeatureMetadata> future = new KafkaFutureImpl<>();
         final long now = time.milliseconds();
+        final NodeProvider nodeProvider = options.nodeId().isPresent() ?
+            new ConstantNodeIdProvider(options.nodeId().getAsInt(), metadataManager.usingBootstrapControllers()) : new LeastLoadedBrokerOrActiveKController();

Review Comment:
   I don't see why we need to use `metadataManager.usingBootstrapControllers()` instead of `true`. This request should be fully supported with the bootstrap controller



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/DescribeFeaturesOptions.java:
##########
@@ -16,8 +16,27 @@
  */
 package org.apache.kafka.clients.admin;
 
+import java.util.OptionalInt;
+
 /**
  * Options for {@link AdminClient#describeFeatures(DescribeFeaturesOptions)}.
  */
 public class DescribeFeaturesOptions extends AbstractOptions<DescribeFeaturesOptions> {
+    private OptionalInt nodeId = OptionalInt.empty();
+
+    /**
+     * Set the node id to which the request should be sent.
+     */

Review Comment:
   The `--bootstrap-controller` and `--bootstrap-broker` are flags in the command. It's not about `Admin`.
   
   For `Admin` interface, it's better to use `bootstrap.controllers` and `bootstrap.servers`. In related document, it already points out the `bootstrap.controllers` builds connection to KRaft controller quorum and `bootstrap.servers` builds connection to Kafka brokers.
   
   https://github.com/apache/kafka/blob/53e117253d21b2cd00e69d6ab91dae0ee84432f2/clients/src/main/java/org/apache/kafka/clients/admin/AdminClientConfig.java#L56-L58
   
   https://github.com/apache/kafka/blob/53e117253d21b2cd00e69d6ab91dae0ee84432f2/clients/src/main/java/org/apache/kafka/clients/CommonClientConfigs.java#L46-L48



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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

   @chia7712 Thanks for the review. I fixed and added related test cases.


-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/DescribeFeaturesOptions.java:
##########
@@ -16,8 +16,27 @@
  */
 package org.apache.kafka.clients.admin;
 
+import java.util.OptionalInt;
+
 /**
  * Options for {@link AdminClient#describeFeatures(DescribeFeaturesOptions)}.
  */
 public class DescribeFeaturesOptions extends AbstractOptions<DescribeFeaturesOptions> {
+    private OptionalInt nodeId = OptionalInt.empty();

Review Comment:
   Would you mind adding this new feature to `upgrade.html`?



##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeFeaturesTest.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * 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.clients.admin;
+
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.server.common.EligibleLeaderReplicasVersion;
+import org.apache.kafka.server.common.Feature;
+import org.apache.kafka.server.common.GroupVersion;
+import org.apache.kafka.server.common.KRaftVersion;
+import org.apache.kafka.server.common.MetadataVersion;
+import org.apache.kafka.server.common.ShareVersion;
+import org.apache.kafka.server.common.StreamsVersion;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class DescribeFeaturesTest {
+
+    @ClusterTest(
+        types = {Type.KRAFT},
+        metadataVersion = MetadataVersion.IBP_3_7_IV0,
+        controllers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(
+                id = 3000,
+                key = "unstable.api.versions.enable",
+                value = "true"
+                ),
+            @ClusterConfigProperty(
+                id = 3001,
+                key = "unstable.api.versions.enable",
+                value = "false"
+                )
+        }
+    )
+    public void testUnstableApiVersionsOnController(ClusterInstance clusterInstance) {
+        try (Admin admin = clusterInstance.admin(Map.of(), true)) {
+            // unstable.api.versions.enable is true on node 3000
+            FeatureMetadata featureMetadata = assertDoesNotThrow(
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(3000)).featureMetadata().get());
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange(Feature.GROUP_VERSION.minimumProduction(), Feature.GROUP_VERSION.latestTesting()),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange(Feature.KRAFT_VERSION.minimumProduction(), Feature.KRAFT_VERSION.latestTesting()),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.MINIMUM_VERSION.featureLevel(), MetadataVersion.latestTesting().featureLevel()),
+                ShareVersion.FEATURE_NAME, new SupportedVersionRange(Feature.SHARE_VERSION.minimumProduction(), Feature.SHARE_VERSION.latestTesting()),
+                StreamsVersion.FEATURE_NAME, new SupportedVersionRange(Feature.STREAMS_VERSION.minimumProduction(), Feature.STREAMS_VERSION.latestTesting()),
+                TransactionVersion.FEATURE_NAME, new SupportedVersionRange(Feature.TRANSACTION_VERSION.minimumProduction(), Feature.TRANSACTION_VERSION.latestTesting()),
+                EligibleLeaderReplicasVersion.FEATURE_NAME, new SupportedVersionRange(Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.minimumProduction(), Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.latestTesting())
+            ), featureMetadata.supportedFeatures());
+
+            // unstable.api.versions.enable is false on node 3001
+            featureMetadata = assertDoesNotThrow(
+                () -> admin.describeFeatures(new DescribeFeaturesOptions().nodeId(3001)).featureMetadata().get());
+            assertEquals(Map.of(
+                GroupVersion.FEATURE_NAME, new SupportedVersionRange(Feature.GROUP_VERSION.minimumProduction(), Feature.GROUP_VERSION.latestProduction()),
+                KRaftVersion.FEATURE_NAME, new SupportedVersionRange(Feature.KRAFT_VERSION.minimumProduction(), Feature.KRAFT_VERSION.latestProduction()),
+                MetadataVersion.FEATURE_NAME, new SupportedVersionRange(MetadataVersion.MINIMUM_VERSION.featureLevel(), MetadataVersion.latestProduction().featureLevel()),
+                ShareVersion.FEATURE_NAME, new SupportedVersionRange(Feature.SHARE_VERSION.minimumProduction(), Feature.SHARE_VERSION.latestProduction()),
+                StreamsVersion.FEATURE_NAME, new SupportedVersionRange(Feature.STREAMS_VERSION.minimumProduction(), Feature.STREAMS_VERSION.latestProduction()),
+                TransactionVersion.FEATURE_NAME, new SupportedVersionRange(Feature.TRANSACTION_VERSION.minimumProduction(), Feature.TRANSACTION_VERSION.latestProduction()),
+                EligibleLeaderReplicasVersion.FEATURE_NAME, new SupportedVersionRange(Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.minimumProduction(), Feature.ELIGIBLE_LEADER_REPLICAS_VERSION.latestProduction())
+            ), featureMetadata.supportedFeatures());
+        }
+    }
+
+    @ClusterTest(
+        types = {Type.KRAFT},
+        metadataVersion = MetadataVersion.IBP_3_7_IV0,
+        brokers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(
+                id = 0,
+                key = "unstable.feature.versions.enable",
+                value = "true"
+                    ),
+            @ClusterConfigProperty(
+                id = 1,
+                key = "unstable.feature.versions.enable",
+                value = "false"
+                    )
+        }
+    )
+    public void testUnstableFeatureVersionsOnBroker(ClusterInstance clusterInstance) {

Review Comment:
   Could you refactor the code to eliminate the similar logic?



-- 
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-18786: add nodeId to DescribeFeaturesOptions [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/admin/DescribeFeaturesOptions.java:
##########
@@ -16,8 +16,27 @@
  */
 package org.apache.kafka.clients.admin;
 
+import java.util.OptionalInt;
+
 /**
  * Options for {@link AdminClient#describeFeatures(DescribeFeaturesOptions)}.
  */
 public class DescribeFeaturesOptions extends AbstractOptions<DescribeFeaturesOptions> {
+    private OptionalInt nodeId = OptionalInt.empty();
+
+    /**
+     * Set the node id to which the request should be sent.
+     */

Review Comment:
   Could you add a note to point out --bootstrap-controller only can send to controller and --bootstrap-broker only can send to broker?
   
   I think user maybe need to know this limitation.



-- 
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