Copilot commented on code in PR #16307:
URL: https://github.com/apache/pinot/pull/16307#discussion_r2206602809
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java:
##########
@@ -463,6 +473,68 @@ public SuccessResponse deleteTable(
"Table '" + tableName + "' with type " + tableType + " does not
exist", Response.Status.NOT_FOUND);
}
+ public static void tableTasksValidation(TableConfig tableConfig,
+ PinotHelixTaskResourceManager pinotHelixTaskResourceManager) {
+ if (tableConfig.getTaskConfig() == null) {
+ return;
+ }
+ String tableWithType = tableConfig.getTableName();
+ Map<String, Map<String, String>> taskTypeConfigsMap =
tableConfig.getTaskConfig().getTaskTypeConfigsMap();
+ for (String taskType : taskTypeConfigsMap.keySet()) {
+ Map<String, TaskState> taskStates;
+ try {
+ taskStates =
pinotHelixTaskResourceManager.getTaskStatesByTable(taskType, tableWithType);
+ } catch (IllegalArgumentException e) {
+ LOGGER.info(e.getMessage());
+ return;
+ }
+ if (!taskStates.isEmpty()) {
+ throw new RuntimeException("The table has dangling task data, try
performing table delete operation in case "
+ + "the delete operation was not completed successfully, else
delete the tasks manually through "
+ + "DELETE /tasks/task/{taskName} endpoint."
+ + "Please try again once the dangling tasks are cleaned up");
Review Comment:
Avoid throwing raw RuntimeException in a REST layer; use a more specific
exception (e.g., ControllerApplicationException) with an appropriate HTTP
status to indicate client error.
```suggestion
throw new ControllerApplicationException(LOGGER,
"The table has dangling task data, try performing table delete
operation in case "
+ "the delete operation was not completed successfully, else
delete the tasks manually through "
+ "DELETE /tasks/task/{taskName} endpoint."
+ "Please try again once the dangling tasks are cleaned up",
Response.Status.BAD_REQUEST);
```
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java:
##########
@@ -463,6 +473,68 @@ public SuccessResponse deleteTable(
"Table '" + tableName + "' with type " + tableType + " does not
exist", Response.Status.NOT_FOUND);
}
+ public static void tableTasksValidation(TableConfig tableConfig,
+ PinotHelixTaskResourceManager pinotHelixTaskResourceManager) {
+ if (tableConfig.getTaskConfig() == null) {
+ return;
+ }
+ String tableWithType = tableConfig.getTableName();
+ Map<String, Map<String, String>> taskTypeConfigsMap =
tableConfig.getTaskConfig().getTaskTypeConfigsMap();
+ for (String taskType : taskTypeConfigsMap.keySet()) {
+ Map<String, TaskState> taskStates;
+ try {
+ taskStates =
pinotHelixTaskResourceManager.getTaskStatesByTable(taskType, tableWithType);
+ } catch (IllegalArgumentException e) {
+ LOGGER.info(e.getMessage());
+ return;
Review Comment:
Returning early on IllegalArgumentException skips validation for remaining
task types; consider logging and continuing the loop instead of exiting.
```suggestion
continue;
```
--
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]