]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: report memory usage, request (limit) in 'orch ps'
authorSage Weil <sage@newdream.net>
Fri, 5 Feb 2021 21:48:59 +0000 (15:48 -0600)
committerSage Weil <sage@newdream.net>
Thu, 20 May 2021 23:00:34 +0000 (18:00 -0500)
Fill in from {osd,mon}_memory_target if no container limit is set.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 4a8182a60658bfbd7034d8eb03e54dc1b154b165)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator/module.py

index fa904b21e3ae8a1ef06433af4ac401c562e1e187..e17c875241612586d40c5b0cb9ab1064e1a3f145 100644 (file)
@@ -1777,6 +1777,11 @@ Then run the following:
                     continue
                 if service_name is not None and service_name != dd.service_name():
                     continue
+                if not dd.memory_request and dd.daemon_type in ['osd', 'mon']:
+                    dd.memory_request = cast(Optional[int], self.get_foreign_ceph_option(
+                        dd.name(),
+                        f"{dd.daemon_type}_memory_target"
+                    ))
                 result.append(dd)
         return result
 
index f8d92dea37cb8e3a0c7d3a7ac36220ec8c693162..94d03243a048775cab4fa13969b61c543da1991b 100644 (file)
@@ -14,7 +14,7 @@ from ceph.deployment.service_spec import PlacementSpec, ServiceSpec
 from ceph.deployment.hostspec import SpecValidationError
 from ceph.utils import datetime_now
 
-from mgr_util import to_pretty_timedelta, format_dimless
+from mgr_util import to_pretty_timedelta, format_dimless, format_bytes
 from mgr_module import MgrModule, HandleCommandResult, Option
 
 from ._interface import OrchestratorClientMixin, DeviceLightLoc, _cli_read_command, \
@@ -32,6 +32,12 @@ def nice_delta(now: datetime.datetime, t: Optional[datetime.datetime], suffix: s
         return '-'
 
 
+def nice_bytes(v: Optional[int]) -> str:
+    if not v:
+        return '-'
+    return format_bytes(v, 5)
+
+
 class Format(enum.Enum):
     plain = 'plain'
     json = 'json'
@@ -632,9 +638,14 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule,
             table = PrettyTable(
                 ['NAME', 'HOST', 'PORTS',
                  'STATUS', 'REFRESHED', 'AGE',
+                 'MEM USE', 'MEM LIM',
                  'VERSION', 'IMAGE ID', 'CONTAINER ID'],
                 border=False)
             table.align = 'l'
+            table._align['REFRESHED'] = 'r'
+            table._align['AGE'] = 'r'
+            table._align['MEM USE'] = 'r'
+            table._align['MEM LIM'] = 'r'
             table.left_padding_width = 0
             table.right_padding_width = 2
             for s in sorted(daemons, key=lambda s: s.name()):
@@ -657,6 +668,8 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule,
                     status,
                     nice_delta(now, s.last_refresh, ' ago'),
                     nice_delta(now, s.created),
+                    nice_bytes(s.memory_usage),
+                    nice_bytes(s.memory_request),
                     ukn(s.version),
                     ukn(s.container_image_id)[0:12],
                     ukn(s.container_id)))