ChenSammi commented on code in PR #9310:
URL: https://github.com/apache/ozone/pull/9310#discussion_r2540906409
##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/AbstractDiskBalancerSubCommand.java:
##########
@@ -77,17 +78,55 @@ public Void call() throws Exception {
// Execute on all target datanodes and collect results
List<String> successNodes = new ArrayList<>();
List<String> failedNodes = new ArrayList<>();
+ List<Object> jsonResults = new ArrayList<>();
+ StringBuilder errorBuilder = new StringBuilder();
+ // Execute commands and collect results
for (String dn : targetDatanodes) {
- if (executeCommand(dn)) {
- successNodes.add(dn);
- } else {
+ try {
+ Object result = executeCommand(dn);
+ if (result != null) {
+ successNodes.add(dn);
+ if (options.isJson()) {
+ jsonResults.add(result);
+ }
+ } else {
+ failedNodes.add(dn);
+ if (options.isJson()) {
+ errorBuilder.append("Error on node [").append(dn)
+ .append("]: Command execution failed\n");
+ }
+ }
+ } catch (Exception e) {
failedNodes.add(dn);
+ String errorMsg = e.getMessage();
+ if (errorMsg != null && errorMsg.contains("\n")) {
+ errorMsg = errorMsg.split("\n", 2)[0];
+ }
+ if (errorMsg == null || errorMsg.isEmpty()) {
+ errorMsg = e.getClass().getSimpleName();
+ }
+ if (options.isJson()) {
+ errorBuilder.append("Error on node [").append(dn)
Review Comment:
If it's json, the failure is expected to be json format, an example,
{
"datanode" : "ozone-datanode-1",
"action" : "start",
"status" : "failure",
"errorMsg": "******* "
"configuration" : {
"stopAfterDiskEven" : false
}
--
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]