You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/06/09 03:52:27 UTC

mesos git commit: Fixed a KeyError exception in mesos-ps.

Repository: mesos
Updated Branches:
  refs/heads/master 0d33b8076 -> 799a3c929


Fixed a KeyError exception in mesos-ps.

Review: https://reviews.apache.org/r/34886


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/799a3c92
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/799a3c92
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/799a3c92

Branch: refs/heads/master
Commit: 799a3c929a2b8a92b22a92022b0d229d677cac2c
Parents: 0d33b80
Author: weitao zhou <zh...@gmail.com>
Authored: Mon Jun 8 18:51:37 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jun 8 18:51:37 2015 -0700

----------------------------------------------------------------------
 src/cli/mesos-ps | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/799a3c92/src/cli/mesos-ps
----------------------------------------------------------------------
diff --git a/src/cli/mesos-ps b/src/cli/mesos-ps
index 8ca7a64..ae48c8c 100755
--- a/src/cli/mesos-ps
+++ b/src/cli/mesos-ps
@@ -65,7 +65,7 @@ def cpus(task, statistics):
     for entry in statistics:
         if (entry['framework_id'] == framework_id and
             entry['executor_id'] == executor_id):
-            cpus_limit = entry['statistics']['cpus_limit']
+            cpus_limit = entry['statistics'].get('cpus_limit', None)
             break
 
     if cpus_limit is not None:
@@ -90,11 +90,11 @@ def mem(task, statistics):
     for entry in statistics:
         if (entry['framework_id'] == framework_id and
             entry['executor_id'] == executor_id):
-            mem_rss_bytes = entry['statistics']['mem_rss_bytes']
-            mem_limit_bytes = entry['statistics']['mem_limit_bytes']
+            mem_rss_bytes = entry['statistics'].get('mem_rss_bytes', None)
+            mem_limit_bytes = entry['statistics'].get('mem_limit_bytes', None)
             break
 
-    if mem_rss_bytes is not None:
+    if mem_rss_bytes is not None and mem_limit_bytes is not None:
         MB = 1024.0 * 1024.0
         return '{usage}/{limit}' \
                 .format(usage = data_size(mem_rss_bytes, "%.1f"),
@@ -129,13 +129,13 @@ def time(task, statistics):
     for entry in statistics:
         if (entry['framework_id'] == framework_id and
             entry['executor_id'] == executor_id):
-            cpus_time_secs = (entry['statistics']['cpus_system_time_secs'] +
-                              entry['statistics']['cpus_user_time_secs'])
+            cpus_system_time_secs = entry['statistics'].get('cpus_system_time_secs', None)
+            cpus_user_time_secs = entry['statistics'].get('cpus_user_time_secs', None)
             break
 
-    if cpus_time_secs is not None:
+    if cpus_system_time_secs is not None and cpus_user_time_secs is not None:
         return (datetime.datetime
-                .utcfromtimestamp(cpus_time_secs)
+                .utcfromtimestamp(cpus_system_time_secs + cpus_user_time_secs)
                 .strftime('%H:%M:%S.%f'))
 
     return None