navinko opened a new pull request, #11275: URL: https://github.com/apache/ozone/pull/11275
## What changes were proposed in this pull request? Updated ContainerBalancer#start() and ContainerBalancer#startBalancer() code to assign startedAt after validation runs. In the existing ContainerBalancer code: > ContainerBalancer#start() and ContainerBalancer#startBalancer() assign startedAt = OffsetDateTime.now() at the very top of the method, before any validation runs. If a start attempt is rejected during validation, startedAt is still advanced even though no new balancing run actually begins. > > After a previous run has completed (so stoppedAt is set), a subsequent rejected start pushes startedAt past stoppedAt. This yields a negative "balancing duration". ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-16387 ## How was this patch tested? - Successful CI : https://github.com/navinko/ozone/actions/runs/35459414407 - Unit testing with new test - TestContainerBalancer#testRejectedStartDoesNotModifyStartedAt which verifies that a start request rejected during validation does not update startedAt of last run. - Tested ContainerBalancer locally. Before Fix > bash-5.1$ ozone admin containerbalancer start -d 10 > Failed to start Container Balancer. max-datanodes-percentage-to-involve-per-iteration=10 allows at most 0 datanode(s) per iteration with 5 eligible datanode(s), but at least 2 are required for a source and target datanode pair. > bash-5.1$ ozone admin containerbalancer status --verbose > ContainerBalancer is Not Running. > Stop reason: INITIALIZATION_FAILED > Message: Failed to initialize a container balancer iteration. Details: iteration number 1, Did not find any unbalanced Datanodes. > Started at: 2026-09-05 19:12:37 > Stopped at: 2026-09-05 15:25:14 > java.lang.IllegalStateException: Provided duration is incorrect: PT-3H-47M-23S > at org.apache.hadoop.hdds.util.DurationUtil.getPrettyDuration(DurationUtil.java:49) > After Fix > bash-5.1$ ozone admin containerbalancer start -d=100 > Container Balancer started successfully. > bash-5.1$ ozone admin containerbalancer status --verbose > ContainerBalancer is Not Running. > Stop reason: INITIALIZATION_FAILED > Message: Failed to initialize a container balancer iteration. Details: iteration number 1, Did not find any unbalanced Datanodes. > Started at: 2026-09-19 13:03:18 > Stopped at: 2026-09-19 13:03:18 > Balancing duration: 0s > bash-5.1$ ozone admin containerbalancer start -d 10 > Failed to start Container Balancer. max-datanodes-percentage-to-involve-per-iteration=10 allows at most 0 datanode(s) per iteration with 5 eligible datanode(s), but at least 2 are required for a source and target datanode pair. > bash-5.1$ ozone admin containerbalancer status --verbose > ContainerBalancer is Not Running. > Stop reason: INITIALIZATION_FAILED > Message: Failed to initialize a container balancer iteration. Details: iteration number 1, Did not find any unbalanced Datanodes. > Started at: 2026-09-19 13:03:18 > Stopped at: 2026-09-19 13:03:18 > Balancing duration: 0s > Started at from last run did not get overridden. -- 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]
