]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/rook: include timestamps in 'orch ps'
authorSage Weil <sage@redhat.com>
Tue, 10 Mar 2020 23:07:59 +0000 (19:07 -0400)
committerSage Weil <sage@redhat.com>
Thu, 12 Mar 2020 21:10:35 +0000 (17:10 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py

index 2bfb0ed5f500d19eddaaef1e628448c849fd110a..15613c2d81dc6ed67dea20864a321a4377bca1b7 100644 (file)
@@ -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
index 4d6828b3f300b9e6a8dfccadd810a034a21a3779..57aec4e7828ff9cdc211c9de04d9bdd749b8dd71 100644 (file)
@@ -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