diff options
author | Sage Weil <sage@redhat.com> | 2020-03-11 00:07:59 +0100 |
---|---|---|
committer | Sage Weil <sage@redhat.com> | 2020-03-12 22:10:35 +0100 |
commit | 68a96122a3f681ec2e5c8986e6562176a89c16f8 (patch) | |
tree | 326807b5538cab6acddf76b396c857904433b546 | |
parent | mgr/orch: shorten container_id (hash) in cephadm, not orch ps (diff) | |
download | ceph-68a96122a3f681ec2e5c8986e6562176a89c16f8.tar.xz ceph-68a96122a3f681ec2e5c8986e6562176a89c16f8.zip |
mgr/rook: include timestamps in 'orch ps'
Signed-off-by: Sage Weil <sage@redhat.com>
-rw-r--r-- | src/pybind/mgr/rook/module.py | 6 | ||||
-rw-r--r-- | src/pybind/mgr/rook/rook_cluster.py | 18 |
2 files changed, 21 insertions, 3 deletions
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 |