From: Sage Weil Date: Mon, 23 Dec 2019 19:19:38 +0000 (-0600) Subject: mgr/orchestrator: include age of 'service ls' metadata X-Git-Tag: v15.1.0~64^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6f7a82f511474ec22f5d500ca46f63691de0ad47;p=ceph.git mgr/orchestrator: include age of 'service ls' metadata Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 73731ea153da..3d055d475f53 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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 diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index a87908798597..35d7e278ebf7 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -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) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 82b3f38ca9d2..9138ff71134a 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -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: '' }[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],