xiangfu0 commented on code in PR #17375:
URL: https://github.com/apache/pinot/pull/17375#discussion_r2630628969


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotInstanceRestletResource.java:
##########
@@ -252,17 +253,20 @@ public SuccessResponse addInstance(
   @Authenticate(AccessType.UPDATE)
   @Produces(MediaType.APPLICATION_JSON)
   @Consumes(MediaType.TEXT_PLAIN)
-  @ApiOperation(value = "Enable/disable an instance", notes = "Enable/disable 
an instance")
+  @ApiOperation(value = "Enable/disable/drain an instance", notes = 
"Enable/disable/drain an instance. "
+      + "DRAIN state is only applicable to minion instances and retags them 
from minion_untagged to minion_drained, "

Review Comment:
   does it mean if a minion is tagged to something else, then we cannot drain 
this node?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -3624,6 +3624,55 @@ public PinotResourceManagerResponse dropInstance(String 
instanceName) {
     return PinotResourceManagerResponse.success("Instance " + instanceName + " 
dropped");
   }
 
+  /**
+   * Drains a minion instance by preventing new task assignments while 
allowing existing tasks to complete.
+   * This is achieved by changing the instance tag from minion_untagged to 
minion_drained, which prevents
+   * Helix from assigning new tasks to this instance.
+   *
+   * @param instanceName Name of the minion instance to drain
+   * @return Response indicating success or failure
+   */
+  public synchronized PinotResourceManagerResponse drainMinionInstance(String 
instanceName) {
+    InstanceConfig instanceConfig = getHelixInstanceConfig(instanceName);
+    if (instanceConfig == null) {
+      return PinotResourceManagerResponse.failure("Instance " + instanceName + 
" not found");
+    }
+
+    // Replace minion_untagged with minion_drained tag
+    List<String> updatedTags = replaceMinionTag(instanceConfig.getTags());

Review Comment:
   we should check, if there is any tag other than `minion-untagged` or default 
tag, then we should just return unsupport exception



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotInstanceRestletResource.java:
##########
@@ -282,6 +286,18 @@ public SuccessResponse toggleInstanceState(
             "Failed to disable instance '" + instanceName + "': " + 
response.getMessage(),
             Response.Status.INTERNAL_SERVER_ERROR);
       }
+    } else if (StateType.DRAIN.name().equalsIgnoreCase(state)) {
+      if (!InstanceTypeUtils.isMinion(instanceName)) {
+        throw new ControllerApplicationException(LOGGER,
+            "DRAIN state only applies to minion instances. Instance '" + 
instanceName + "' is not a minion.",
+            Response.Status.BAD_REQUEST);
+      }
+      PinotResourceManagerResponse response = 
_pinotHelixResourceManager.drainMinionInstance(instanceName);

Review Comment:
   if a minion is in drained mode, when the same minion come up again, the tag 
is still drained, then it won't be able to serve tasks 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to