You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by sa...@apache.org on 2018/04/20 20:29:46 UTC

aurora git commit: Fix the json endpoints in thermos

Repository: aurora
Updated Branches:
  refs/heads/master 38aae0fdc -> 02a685117


Fix the json endpoints in thermos

# Fixing the json endpoints in thermos

`TaskObserverJSONBindings` is mixin that includes a few routes that serve info about tasks and processes in pure JSON format. The functions are overridden in the main bottle server, so the routes are not accessible. This patch fixes it by renaming those methods.

Check here:
https://github.com/apache/aurora/blob/master/src/main/python/apache/thermos/observer/http/http_observer.py#L72

Testing Done:
There was no unit test affected.

After fixing the routes server the expected content.
```
? curl http://192.168.33.7:1338/j/task_ids
{"type": "all", "tasks": [{"status": "sleeping", "ram": 3727360, "state_timestamp": 1523728477, "threads": 2, "user": 0.24, "disk": 10117120, "launch_timestamp": 1523728477, "vms": 22990848, "rss": 3727360, "name": "hello", "task_id": "www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098", "system": 0.34, "ports": {}, "state": "ACTIVE", "role": "www-data", "cpu": 0.0, "nice": 0}], "num": 20, "task_count": 1, "offset": 0}%

? curl http://192.168.33.7:1338/j/task/www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098
{"www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098": {"task": {"processes": [{"daemon": false, "name": "hello", "max_failures": 1, "ephemeral": false, "min_duration": 5, "cmdline": "\n    while true; do\n      echo hello world\n      sleep 10\n    done\n  ", "final": false}], "name": "hello", "finalization_wait": 30, "max_failures": 1, "max_concurrency": 0, "resources": {"gpu": 0, "disk": 134217728, "ram": 134217728, "cpu": 1.0}, "constraints": [{"order": ["hello"]}]}, "name": "hello", "task_id": "www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098", "processes": {"failed": [], "running": ["hello"], "killed": [], "success": [], "waiting": []}, "state_timestamp": 1523728477, "state": "ACTIVE", "resource_consumption": {"status": "sleeping", "disk": 10113024, "ram": 3719168, "system": 0.33, "vms": 22990848, "threads": 2, "user": 0.24, "rss": 3719168, "cpu": 0.0, "nice": 0}, "user": "www-data", "launch_timestamp": 1523728477, "ports": {}}}%

? curl http://192.168.33.7:1338/j/task\?task_id\=www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098
{"www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098": {"task": {"processes": [{"daemon": false, "name": "hello", "max_failures": 1, "ephemeral": false, "min_duration": 5, "cmdline": "\n    while true; do\n      echo hello world\n      sleep 10\n    done\n  ", "final": false}], "name": "hello", "finalization_wait": 30, "max_failures": 1, "max_concurrency": 0, "resources": {"gpu": 0, "disk": 134217728, "ram": 134217728, "cpu": 1.0}, "constraints": [{"order": ["hello"]}]}, "name": "hello", "task_id": "www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098", "processes": {"failed": [], "running": ["hello"], "killed": [], "success": [], "waiting": []}, "state_timestamp": 1523728477, "state": "ACTIVE", "resource_consumption": {"status": "sleeping", "disk": 10141696, "ram": 3731456, "system": 0.35, "vms": 22994944, "threads": 2, "user": 0.24, "rss": 3731456, "cpu": 0.0, "nice": 0}, "user": "www-data", "launch_timestamp": 1523728477, "ports": {}}}%

? curl http://192.168.33.7:1338/j/process/www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098/hello/0
{"state": "RUNNING", "process_name": "hello", "used": {"status": "sleeping", "ram": 3735552, "system": 0.34, "vms": 22990848, "threads": 2, "user": 0.24, "rss": 3735552, "cpu": 0.0, "nice": 0}, "start_time": 1523728477.867429, "process_run": 0}%

? curl http://192.168.33.7:1338/j/processes\?task_id\=www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098
{"www-data-prod-hello-0-00e58d09-a67f-4a46-94a0-15bcad26a098": {"hello": {"state": "RUNNING", "process_name": "hello", "used": {"status": "sleeping", "ram": 3735552, "system": 0.35, "vms": 22994944, "threads": 2, "user": 0.25, "rss": 3735552, "cpu": 0.0005000061512750167, "nice": 0}, "start_time": 1523728477.867429, "process_run": 0}}}%
```

Reviewed at https://reviews.apache.org/r/66623/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/02a68511
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/02a68511
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/02a68511

Branch: refs/heads/master
Commit: 02a685117562e8eec81a0d4546fbbf300d8a7893
Parents: 38aae0f
Author: Reza Motamedi <re...@gmail.com>
Authored: Fri Apr 20 13:29:24 2018 -0700
Committer: Santhosh Kumar <ss...@twitter.com>
Committed: Fri Apr 20 13:29:24 2018 -0700

----------------------------------------------------------------------
 src/main/python/apache/thermos/observer/http/json.py | 14 +++++++-------
 src/test/python/apache/thermos/observer/http/BUILD   |  1 +
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/02a68511/src/main/python/apache/thermos/observer/http/json.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/thermos/observer/http/json.py b/src/main/python/apache/thermos/observer/http/json.py
index 4ba5324..e4473d6 100644
--- a/src/main/python/apache/thermos/observer/http/json.py
+++ b/src/main/python/apache/thermos/observer/http/json.py
@@ -26,18 +26,18 @@ class TaskObserverJSONBindings(object):
   @HttpServer.route("/j/task_ids/:which")
   @HttpServer.route("/j/task_ids/:which/:offset")
   @HttpServer.route("/j/task_ids/:which/:offset/:num")
-  def handle_task_ids(self, which=None, offset=None, num=None):
-    return self._observer.task_ids(
+  def handle_json_task_ids(self, which=None, offset=None, num=None):
+    return self._observer.main(
       which,
       int(offset) if offset is not None else 0,
       int(num) if num is not None else 20)
 
   @HttpServer.route("/j/task_id_count")
-  def handle_task_id_count(self):
+  def handle_json_task_id_count(self):
     return self._observer.task_id_count()
 
   @HttpServer.route("/j/task")
-  def handle_tasks(self):
+  def handle_json_tasks(self):
     """
       Additional parameters:
         task_id = comma separated list of task_ids.
@@ -48,17 +48,17 @@ class TaskObserverJSONBindings(object):
     return self._observer.tasks(task_ids)
 
   @HttpServer.route("/j/task/:task_id")
-  def handle_task(self, task_id):
+  def handle_json_task(self, task_id):
     return self._observer.tasks([task_id])
 
   @HttpServer.route("/j/process/:task_id")
   @HttpServer.route("/j/process/:task_id/:process")
   @HttpServer.route("/j/process/:task_id/:process/:run")
-  def handle_process(self, task_id, process=None, run=None):
+  def handle_json_process(self, task_id, process=None, run=None):
     return self._observer.process(task_id, process, run)
 
   @HttpServer.route("/j/processes")
-  def handle_processes(self):
+  def handle_json_processes(self):
     """
       Additional parameters:
         task_ids = comma separated list of task_ids.

http://git-wip-us.apache.org/repos/asf/aurora/blob/02a68511/src/test/python/apache/thermos/observer/http/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/apache/thermos/observer/http/BUILD b/src/test/python/apache/thermos/observer/http/BUILD
index 708f09b..b963311 100644
--- a/src/test/python/apache/thermos/observer/http/BUILD
+++ b/src/test/python/apache/thermos/observer/http/BUILD
@@ -17,6 +17,7 @@ python_tests(
   sources = globs('*.py'),
   dependencies = [
     '3rdparty/python:mock',
+    '3rdparty/python:requests',
     'src/main/python/apache/thermos/monitoring',
     'src/main/python/apache/thermos/observer',
   ]