From: Sage Weil Date: Tue, 10 Mar 2020 23:07:59 +0000 (-0400) Subject: mgr/rook: include timestamps in 'orch ps' X-Git-Tag: v15.1.1~8^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=68a96122a3f681ec2e5c8986e6562176a89c16f8;p=ceph-ci.git mgr/rook: include timestamps in 'orch ps' Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 2bfb0ed5f50..15613c2d81d 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -287,6 +287,12 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): continue sd.container_image_name = p['container_image_name'] + + sd.created = p['created'] + sd.last_configured = p['created'] + sd.last_deployed = p['created'] + sd.started = p['started'] + sd.last_refresh = p['refreshed'] result.append(sd) return result diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 4d6828b3f30..57aec4e7828 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -6,6 +6,7 @@ call methods. This module is runnable outside of ceph-mgr, useful for testing. """ +import datetime import threading import logging import json @@ -313,13 +314,13 @@ class RookCluster(object): return False return True + refreshed = datetime.datetime.utcnow() pods = [i for i in self.rook_pods.items if predicate(i)] pods_summary = [] for p in pods: d = p.to_dict() - # p['metadata']['creationTimestamp'] image_name = None for c in d['spec']['containers']: @@ -327,13 +328,24 @@ class RookCluster(object): image_name = c['image'] break - pods_summary.append({ + s = { "name": d['metadata']['name'], "hostname": d['spec']['node_name'], "labels": d['metadata']['labels'], 'phase': d['status']['phase'], 'container_image_name': image_name, - }) + 'refreshed': refreshed, + } + + # note: we want UTC but no tzinfo + if 'creation_timestamp' in d['metadata']: + s['created'] = d['metadata']['creation_timestamp'].astimezone( + tz=datetime.timezone.utc).replace(tzinfo=None) + if 'start_time' in d['status']: + s['started'] = d['status']['start_time'].astimezone( + tz=datetime.timezone.utc).replace(tzinfo=None) + + pods_summary.append(s) return pods_summary