]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/balancer: Improved 'ceph balancer status' output
authorNico Wang <wangn4@rpi.edu>
Tue, 10 Oct 2023 21:00:29 +0000 (21:00 +0000)
committerChristopher Poon <poonc3@rpi.edu>
Mon, 11 Dec 2023 07:20:21 +0000 (07:20 +0000)
We have recently introduced a detailed command to check the status of our balancer.
This command displays the location of pg_up_map items where they are being transferred
when the balancer runs. The primary objective of this command is to obtain a better
understanding of the balancer's behavior in terms of transferring pgs. This will help
us identify when the balancing is taking place in the effort to improve the balancing
process to evenly distribute pgs in the balancing process.

Signed-off-by: Christopher Poon <poon3@rpi.edu>
Signed-off-by: Zuriel Aviles <avilez@rpi.edu>
Signed-off-by: Nico Wang <wangn4@rpi.edu>
src/pybind/mgr/balancer/module.py

index 1c40425115cfaaa5ad6ae9040f7daf139dbb84b8..590f24653f0c40509b39296a054380da0d2904e7 100644 (file)
@@ -327,6 +327,9 @@ class Module(MgrModule):
     no_optimization_needed = False
     success_string = 'Optimization plan created successfully'
     in_progress_string = 'in progress'
+    last_pg_upmap: List[Dict[str, Any]] = []
+    added_pg_upmap_items: List[Dict[str, Any]] = []
+    removed_pg_upmap_items: List[Dict[str, Any]] = []
 
     def __init__(self, *args: Any, **kwargs: Any) -> None:
         super(Module, self).__init__(*args, **kwargs)
@@ -348,6 +351,24 @@ class Module(MgrModule):
         }
         return (0, json.dumps(s, indent=4, sort_keys=True), '')
 
+    @CLIReadCommand('balancer status detail')
+    def show_status_detail(self) -> Tuple[int, str, str]:
+        """
+        Show balancer status (detailed)
+        """
+        s = {
+            'plans': list(self.plans.keys()),
+            'active': self.active,
+            'last_optimize_started': self.last_optimize_started,
+            'last_optimize_duration': self.last_optimize_duration,
+            'optimize_result': self.optimize_result,
+            'no_optimization_needed': self.no_optimization_needed,
+            'mode': self.get_module_option('mode'),
+            'added_pg_upmap_items': self.added_pg_upmap_items,
+            'removed_pg_upmap_items': self.removed_pg_upmap_items,
+        }
+        return (0, json.dumps(s, indent=4), '')
+
     @CLICommand('balancer mode')
     def set_mode(self, mode: Mode) -> Tuple[int, str, str]:
         """
@@ -693,6 +714,9 @@ class Module(MgrModule):
                 start = time.time()
                 r, detail = self.optimize(plan)
                 end = time.time()
+                self.added_pg_upmap_items = [pg for pg in osdmap.dump().get('pg_upmap_items', '') if pg not in self.last_pg_upmap]
+                self.removed_pg_upmap_items = [pg for pg in self.last_pg_upmap if pg not in osdmap.dump().get('pg_upmap_items', '')]
+                self.last_pg_upmap = osdmap.dump().get('pg_upmap_items', '')
                 self.last_optimize_duration = str(datetime.timedelta(seconds=(end - start)))
                 if r == 0:
                     self.optimize_result = self.success_string