You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "LiebingYu (via GitHub)" <gi...@apache.org> on 2026/03/17 08:22:03 UTC

[PR] [client] Support specifying rack when adding/removing server tags in Admin API [fluss]

LiebingYu opened a new pull request, #2890:
URL: https://github.com/apache/fluss/pull/2890

   
   
   <!--
   *Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/fluss/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
   
     - Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink]). Skip *[component]* if you are unsure about which is the best component.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
   
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
   
   
   **(The sections below can be removed for hotfixes or typos)**
   -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Linked issue: close #2889 
   
   <!-- What is the purpose of the change -->
   
   ### Brief change log
   
   <!-- Please describe the changes made in this pull request and explain how they address the issue -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@fluss.apache.org

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


Re: [PR] [client] Support specifying rack when adding/removing server tags in Admin API [fluss]

Posted by "swuferhong (via GitHub)" <gi...@apache.org>.
swuferhong commented on code in PR #2890:
URL: https://github.com/apache/fluss/pull/2890#discussion_r3837969563


##########
fluss-client/src/main/java/org/apache/fluss/client/admin/Admin.java:
##########
@@ -654,6 +661,104 @@ ListOffsetsResult listOffsets(
      */
     CompletableFuture<Void> removeServerTag(List<Integer> tabletServers, ServerTag serverTag);
 
+    /**
+     * Add server tag to all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to add the tag, none of the tags will take effect.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagAlreadyExistException} If the server tag already exists for any one of
+     *       the matched tabletServers, and the server tag is different from the existing one.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be added.
+     */
+    default CompletableFuture<Void> addServerTagByRack(List<String> racks, ServerTag serverTag) {

Review Comment:
   Why are these two implementations placed directly in the `Admin` interface?



##########
fluss-client/src/main/java/org/apache/fluss/client/admin/Admin.java:
##########
@@ -654,6 +661,104 @@ ListOffsetsResult listOffsets(
      */
     CompletableFuture<Void> removeServerTag(List<Integer> tabletServers, ServerTag serverTag);
 
+    /**
+     * Add server tag to all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to add the tag, none of the tags will take effect.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagAlreadyExistException} If the server tag already exists for any one of
+     *       the matched tabletServers, and the server tag is different from the existing one.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be added.
+     */
+    default CompletableFuture<Void> addServerTagByRack(List<String> racks, ServerTag serverTag) {
+        checkNotNull(racks, "racks must not be null");
+        checkArgument(!racks.isEmpty(), "racks must not be empty");
+        racks.forEach(
+                r ->
+                        checkArgument(
+                                r != null && !r.isEmpty(),
+                                "rack element must not be null or empty"));
+        Set<String> rackSet = new HashSet<>(racks);
+        return getServerNodes()

Review Comment:
   `getServerNodes()` obtains cluster membership from a random TabletServer's metadata cache, which may lag behind the Coordinator. 
   
   Even with a fresh response, resolving the rack and updating the tags in two separate RPCs leaves a race window between the two operations. Please consider resolving the rack membership and updating the tags in a single Coordinator RPC/event so that the documented “all TabletServers belonging to the specified racks” behavior uses a consistent membership snapshot. 
   
   The same issue applies to `removeServerTagByRack()`.



##########
fluss-client/src/main/java/org/apache/fluss/client/admin/Admin.java:
##########
@@ -654,6 +661,104 @@ ListOffsetsResult listOffsets(
      */
     CompletableFuture<Void> removeServerTag(List<Integer> tabletServers, ServerTag serverTag);
 
+    /**
+     * Add server tag to all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to add the tag, none of the tags will take effect.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagAlreadyExistException} If the server tag already exists for any one of
+     *       the matched tabletServers, and the server tag is different from the existing one.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be added.
+     */
+    default CompletableFuture<Void> addServerTagByRack(List<String> racks, ServerTag serverTag) {
+        checkNotNull(racks, "racks must not be null");
+        checkArgument(!racks.isEmpty(), "racks must not be empty");
+        racks.forEach(
+                r ->
+                        checkArgument(
+                                r != null && !r.isEmpty(),
+                                "rack element must not be null or empty"));
+        Set<String> rackSet = new HashSet<>(racks);
+        return getServerNodes()
+                .thenCompose(
+                        nodes -> {
+                            List<Integer> serverIds =
+                                    nodes.stream()
+                                            .filter(
+                                                    n ->
+                                                            n.serverType()
+                                                                            == ServerType
+                                                                                    .TABLET_SERVER
+                                                                    && rackSet.contains(n.rack()))
+                                            .map(ServerNode::id)
+                                            .collect(Collectors.toList());
+                            if (serverIds.isEmpty()) {
+                                return CompletableFuture.completedFuture(null);

Review Comment:
   This early return skips both serverTag validation and the ALTER authorization performed by `addServerTag()`. As a result, addServerTagByRack(missingRack, null) succeeds, and a caller without ALTER permission also receives success when no rack matches. The outcome therefore depends on whether the rack currently exists and contradicts the documented exception behavior.
   
   Please validate serverTag before resolving the racks and ensure that authorization is checked even for a no-op. 
   
   The corresponding early return in removeServerTagByRack() has the same problem.



##########
fluss-client/src/main/java/org/apache/fluss/client/admin/Admin.java:
##########
@@ -654,6 +661,104 @@ ListOffsetsResult listOffsets(
      */
     CompletableFuture<Void> removeServerTag(List<Integer> tabletServers, ServerTag serverTag);
 
+    /**
+     * Add server tag to all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to add the tag, none of the tags will take effect.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagAlreadyExistException} If the server tag already exists for any one of
+     *       the matched tabletServers, and the server tag is different from the existing one.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be added.
+     */
+    default CompletableFuture<Void> addServerTagByRack(List<String> racks, ServerTag serverTag) {
+        checkNotNull(racks, "racks must not be null");
+        checkArgument(!racks.isEmpty(), "racks must not be empty");
+        racks.forEach(
+                r ->
+                        checkArgument(
+                                r != null && !r.isEmpty(),
+                                "rack element must not be null or empty"));
+        Set<String> rackSet = new HashSet<>(racks);
+        return getServerNodes()
+                .thenCompose(
+                        nodes -> {
+                            List<Integer> serverIds =
+                                    nodes.stream()
+                                            .filter(
+                                                    n ->
+                                                            n.serverType()
+                                                                            == ServerType
+                                                                                    .TABLET_SERVER
+                                                                    && rackSet.contains(n.rack()))
+                                            .map(ServerNode::id)
+                                            .collect(Collectors.toList());
+                            if (serverIds.isEmpty()) {
+                                return CompletableFuture.completedFuture(null);
+                            }
+                            return addServerTag(serverIds, serverTag);
+                        });
+    }
+
+    /**
+     * Remove server tag from all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to remove the tag, none of the tags will be removed.
+     *
+     * <p>No exception will be thrown if a matched server already has no server tag.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagNotExistException} If the server tag does not exist for any one of the
+     *       matched tabletServers.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be removed.
+     */
+    default CompletableFuture<Void> removeServerTagByRack(List<String> racks, ServerTag serverTag) {
+        checkNotNull(racks, "racks must not be null");
+        checkArgument(!racks.isEmpty(), "racks must not be empty");
+        racks.forEach(
+                r ->
+                        checkArgument(
+                                r != null && !r.isEmpty(),
+                                "rack element must not be null or empty"));
+        Set<String> rackSet = new HashSet<>(racks);
+        return getServerNodes()

Review Comment:
   `removeServerTagByRack()` only resolves IDs from `getServerNodes()`, which returns the currently alive TabletServers. Once all servers in a rack have gone offline, this method resolves an empty ID list and returns success without removing their tags.
   
   This is asymmetric with `removeServerTag(List<Integer>, ServerTag)`: the Coordinator-side `processRemoveServerTag()` explicitly tolerates a missing server and still removes its tag. Therefore, a tag applied before decommissioning cannot later be cleaned up by rack after the physical host has gone offline; it remains in ZooKeeper and coordinatorContext until the caller removes it explicitly by server ID.
   
   Please preserve enough rack-to-server information to resolve tagged offline servers. Moving rack resolution to the Coordinator is preferable, but it also requires persisting the rack association—for example, storing the rack together with the server tag or retaining historical server metadata—because the live registration is removed when the server goes offline. If this API is intentionally limited to alive servers, that limitation should at least be stated explicitly in its Javadoc and user documentation.



-- 
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: issues-unsubscribe@fluss.apache.org

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


Re: [PR] [client] Support specifying rack when adding/removing server tags in Admin API [fluss]

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


-- 
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: issues-unsubscribe@fluss.apache.org

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


Re: [PR] [client] Support specifying rack when adding/removing server tags in Admin API [fluss]

Posted by "LiebingYu (via GitHub)" <gi...@apache.org>.
LiebingYu commented on code in PR #2890:
URL: https://github.com/apache/fluss/pull/2890#discussion_r3944007407


##########
fluss-client/src/main/java/org/apache/fluss/client/admin/Admin.java:
##########
@@ -654,6 +661,104 @@ ListOffsetsResult listOffsets(
      */
     CompletableFuture<Void> removeServerTag(List<Integer> tabletServers, ServerTag serverTag);
 
+    /**
+     * Add server tag to all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to add the tag, none of the tags will take effect.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagAlreadyExistException} If the server tag already exists for any one of
+     *       the matched tabletServers, and the server tag is different from the existing one.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be added.
+     */
+    default CompletableFuture<Void> addServerTagByRack(List<String> racks, ServerTag serverTag) {
+        checkNotNull(racks, "racks must not be null");
+        checkArgument(!racks.isEmpty(), "racks must not be empty");
+        racks.forEach(
+                r ->
+                        checkArgument(
+                                r != null && !r.isEmpty(),
+                                "rack element must not be null or empty"));
+        Set<String> rackSet = new HashSet<>(racks);
+        return getServerNodes()
+                .thenCompose(
+                        nodes -> {
+                            List<Integer> serverIds =
+                                    nodes.stream()
+                                            .filter(
+                                                    n ->
+                                                            n.serverType()
+                                                                            == ServerType
+                                                                                    .TABLET_SERVER
+                                                                    && rackSet.contains(n.rack()))
+                                            .map(ServerNode::id)
+                                            .collect(Collectors.toList());
+                            if (serverIds.isEmpty()) {
+                                return CompletableFuture.completedFuture(null);
+                            }
+                            return addServerTag(serverIds, serverTag);
+                        });
+    }
+
+    /**
+     * Remove server tag from all tabletServers belonging to any of the specified racks.
+     *
+     * <p>If no tabletServer is found for any of the given racks, the operation completes
+     * successfully without making any changes.
+     *
+     * <p>If any tabletServer fails to remove the tag, none of the tags will be removed.
+     *
+     * <p>No exception will be thrown if a matched server already has no server tag.
+     *
+     * <ul>
+     *   <li>{@link AuthorizationException} If the authenticated user doesn't have cluster
+     *       permissions.
+     *   <li>{@link ServerTagNotExistException} If the server tag does not exist for any one of the
+     *       matched tabletServers.
+     * </ul>
+     *
+     * @param racks the list of rack identifiers; all tabletServers whose {@link ServerNode#rack()}
+     *     is contained in this list will be targeted. Must not be null or empty.
+     * @param serverTag the server tag to be removed.
+     */
+    default CompletableFuture<Void> removeServerTagByRack(List<String> racks, ServerTag serverTag) {
+        checkNotNull(racks, "racks must not be null");
+        checkArgument(!racks.isEmpty(), "racks must not be empty");
+        racks.forEach(
+                r ->
+                        checkArgument(
+                                r != null && !r.isEmpty(),
+                                "rack element must not be null or empty"));
+        Set<String> rackSet = new HashSet<>(racks);
+        return getServerNodes()

Review Comment:
   Thanks, this is a valid point. I’m intentionally keeping removeServerTagByRack() as a one-shot convenience selector over the Coordinator’s currently registered TabletServers, rather than introducing persistent rack membership history.
   
   Consequently, it does not remove tags from servers that are already offline or no longer belong to their former rack. Those tags remain persisted by server ID and should be cleared with removeServerTag(serverIds, tag), especially before a server ID is reused.
   
   I have documented this limitation explicitly in the JavaDoc and user documentation. The external cordon prevents new servers from entering the rack during decommissioning, but does not change this removal limitation.
   
   If removing offline servers by rack is required as part of the API contract, I think that should be handled by a separate rack-history/policy design rather than adding that state implicitly in this PR.



-- 
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: issues-unsubscribe@fluss.apache.org

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


Re: [PR] [client] Support specifying rack when adding/removing server tags in Admin API [fluss]

Posted by "LiebingYu (via GitHub)" <gi...@apache.org>.
LiebingYu commented on PR #2890:
URL: https://github.com/apache/fluss/pull/2890#issuecomment-4073176967

   Hi @swuferhong, PTAL!


-- 
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: issues-unsubscribe@fluss.apache.org

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