]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: include age of 'service ls' metadata
authorSage Weil <sage@redhat.com>
Mon, 23 Dec 2019 19:19:38 +0000 (13:19 -0600)
committerSage Weil <sage@redhat.com>
Fri, 24 Jan 2020 14:54:20 +0000 (08:54 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py

index 73731ea153da030e54f0e01b2de322711eb3b581..3d055d475f53af57dc867110436c2d04321f234f 100644 (file)
@@ -22,6 +22,7 @@ import subprocess
 
 from ceph.deployment import inventory
 from mgr_module import MgrModule
+import mgr_util
 import orchestrator
 from orchestrator import OrchestratorError, HostSpec, OrchestratorValidationError
 
index a879087985973820aa6be5856447f4f2428ab61e..35d7e278ebf70cf2b4efd0b2d832617c41e23b2e 100644 (file)
@@ -1167,6 +1167,9 @@ class ServiceDescription(object):
         # Service status description when status == -1.
         self.status_desc = status_desc
 
+        # datetime when this info was last refreshed
+        self.last_refresh = None   # type: Optional[datetime.datetime]
+
     def name(self):
         if self.service_instance:
             return '%s.%s' % (self.service_type, self.service_instance)
index 82b3f38ca9d2cfac4d9d6a0d5921e720612d9feb..9138ff71134abe4049105b264f96c8cf1955c176 100644 (file)
@@ -1,3 +1,4 @@
+import datetime
 import errno
 import json
 from functools import wraps
@@ -5,7 +6,7 @@ from functools import wraps
 from ceph.deployment.inventory import Device
 from prettytable import PrettyTable
 
-from mgr_util import format_bytes
+from mgr_util import format_bytes, to_pretty_timedelta
 
 try:
     from typing import List, Set, Optional
@@ -299,8 +300,9 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
             data = [s.to_json() for s in services]
             return HandleCommandResult(stdout=json.dumps(data))
         else:
+            now = datetime.datetime.utcnow()
             table = PrettyTable(
-                ['NAME', 'HOST', 'STATUS',
+                ['NAME', 'HOST', 'STATUS', 'REFRESHED',
                  'VERSION', 'IMAGE NAME', 'IMAGE ID', 'CONTAINER ID'],
                 border=False)
             table.align = 'l'
@@ -314,10 +316,15 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
                     None: '<unknown>'
                 }[s.status]
 
+                if s.last_refresh:
+                    age = to_pretty_timedelta(now - s.last_refresh) + ' ago'
+                else:
+                    age = '-'
                 table.add_row((
                     s.name(),
                     ukn(s.nodename),
                     status,
+                    age,
                     ukn(s.version),
                     ukn(s.container_image_name),
                     ukn(s.container_image_id)[0:12],