You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by mc...@apache.org on 2014/10/21 20:08:54 UTC

git commit: Make v2 job status look more like v1.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 4ad14475d -> 69c3f3735


Make v2 job status look more like v1.

Adds a header line to each task in a task status line specifying the
instance number, host, etc., the way v1 did. (We had originally
planned not to display that information in v2, but we also have tests
that depend on it being present.)

Bugs closed: AURORA-874

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


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

Branch: refs/heads/master
Commit: 69c3f3735a309f650261012f1c2d8ef0b5493b30
Parents: 4ad1447
Author: Mark Chu-Carroll <mc...@twopensource.com>
Authored: Tue Oct 21 14:05:43 2014 -0400
Committer: Mark Chu-Carroll <mc...@twitter.com>
Committed: Tue Oct 21 14:05:43 2014 -0400

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/jobs.py     | 16 ++++++++++----
 .../apache/aurora/client/cli/test_status.py     | 22 ++++++++++++--------
 2 files changed, 25 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/69c3f373/src/main/python/apache/aurora/client/cli/jobs.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/jobs.py b/src/main/python/apache/aurora/client/cli/jobs.py
index 7bbde15..6c11f15 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -455,7 +455,7 @@ class RestartCommand(Verb):
              help='Maximum number of restarts per instance during restart. Increments total '
                   'failure count when this limit is exceeded.'),
         CommandOption('--restart-threshold', type=int, default=60,
-             help='Maximum number of seconds before a shard must move into the RUNNING state '
+             help='Maximum number of seconds before an instance must move into the RUNNING state '
                   'before considered a failure.'),
         CONFIG_OPTION,
         MAX_TOTAL_FAILURES_OPTION,
@@ -467,12 +467,12 @@ class RestartCommand(Verb):
   @property
   def help(self):
     return textwrap.dedent("""\
-        Perform a rolling restart of shards within a job.
+        Perform a rolling restart of instances within a job.
         Restarts are fully controlled client-side, so aborting halts the restart.""")
 
   def execute(self, context):
     # Check for negative max_total_failures option - negative is an error.
-    # for per-shard failures, negative means "no limit", so it's allowed.
+    # for per-instance failures, negative means "no limit", so it's allowed.
     if context.options.max_total_failures < 0:
       context.print_err("max_total_failures option must be >0, but you specified %s" %
           context.options.max_total_failures)
@@ -552,7 +552,15 @@ class StatusCommand(Verb):
     def render_task_pretty(scheduled_task):
       assigned_task = scheduled_task.assignedTask
       task_info = assigned_task.task
-      task_strings = ["\tTask:"]
+      task_strings = []
+      task_strings.append("\tTask role: %s, env: %s, name: %s, instance: %s, status: %s on %s" %
+             (scheduled_task.assignedTask.task.owner.role,
+              scheduled_task.assignedTask.task.environment,
+              scheduled_task.assignedTask.task.jobName,
+              scheduled_task.assignedTask.instanceId,
+              ScheduleStatus._VALUES_TO_NAMES[scheduled_task.status],
+              scheduled_task.assignedTask.slaveHost))
+
       if task_info:
         task_strings.append("""\t  cpus: %s, ram: %s MB, disk: %s MB""" % (
             task_info.numCpus, task_info.ramMb, task_info.diskMb))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/69c3f373/src/test/python/apache/aurora/client/cli/test_status.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_status.py b/src/test/python/apache/aurora/client/cli/test_status.py
index c704dae..4f62cf0 100644
--- a/src/test/python/apache/aurora/client/cli/test_status.py
+++ b/src/test/python/apache/aurora/client/cli/test_status.py
@@ -43,6 +43,9 @@ class TestJobStatus(AuroraClientCommandTest):
   def create_mock_scheduled_tasks(cls):
     jobs = []
     for name in ['foo', 'bar', 'baz']:
+      instance = 7734  # use a fake instance number; the order in which the status request
+      # returns the shards isn't really deterministic - it's up to python sorting.
+      # so for testing, just use the same one for all shards.
       job = Mock()
       job.key = JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=name)
       job.failure_count = 0
@@ -57,7 +60,7 @@ class TestJobStatus(AuroraClientCommandTest):
       job.assignedTask.task.numCpus = 2
       job.assignedTask.task.ramMb = 2
       job.assignedTask.task.diskMb = 2
-      job.assignedTask.instanceId = 4237894
+      job.assignedTask.instanceId = instance
       job.assignedTask.assignedPorts = None
       job.status = ScheduleStatus.RUNNING
       mockEvent = Mock(spec=TaskEvent)
@@ -149,7 +152,7 @@ class TestJobStatus(AuroraClientCommandTest):
       task.assignedTask.task.production = False
       task.assignedTask.task.requestedPorts = ["http"]
       task.assignedTask.assignedPorts = {"http": 1001}
-      task.assignedTask.instanceId = 0
+      task.assignedTask.instanceId = instance
       task.status = 2
       task.failureCount = instance + 4
       task.taskEvents = create_task_events(start_time)
@@ -234,15 +237,15 @@ class TestJobStatus(AuroraClientCommandTest):
       actual = re.sub("\\d\\d:\\d\\d:\\d\\d", "##:##:##", '\n'.join(mock_context.get_out()))
       expected = textwrap.dedent("""\
           Active tasks (3):
-          \tTask:
+          \tTask role: bozo, env: test, name: woops, instance: 7734, status: RUNNING on slavehost
           \t  cpus: 2, ram: 2 MB, disk: 2 MB
           \t  events:
           \t   1970-11-23 ##:##:## RUNNING: Hi there
-          \tTask:
+          \tTask role: bozo, env: test, name: woops, instance: 7734, status: RUNNING on slavehost
           \t  cpus: 2, ram: 2 MB, disk: 2 MB
           \t  events:
           \t   1970-11-23 ##:##:## RUNNING: Hi there
-          \tTask:
+          \tTask role: bozo, env: test, name: woops, instance: 7734, status: RUNNING on slavehost
           \t  cpus: 2, ram: 2 MB, disk: 2 MB
           \t  events:
           \t   1970-11-23 ##:##:## RUNNING: Hi there
@@ -263,21 +266,21 @@ class TestJobStatus(AuroraClientCommandTest):
       actual = re.sub("\\d\\d:\\d\\d:\\d\\d", "##:##:##", '\n'.join(mock_context.get_out()))
       expected = textwrap.dedent("""\
           Active tasks (3):
-          \tTask:
+          \tTask role: bozo, env: test, name: woops, instance: 7734, status: RUNNING on slavehost
           \t  cpus: 2, ram: 2 MB, disk: 2 MB
           \t  events:
           \t   1970-11-23 ##:##:## RUNNING: Hi there
           \t  metadata:
           \t\t  (key: 'meta', value: 'data')
           \t\t  (key: 'data', value: 'meta')
-          \tTask:
+          \tTask role: bozo, env: test, name: woops, instance: 7734, status: RUNNING on slavehost
           \t  cpus: 2, ram: 2 MB, disk: 2 MB
           \t  events:
           \t   1970-11-23 ##:##:## RUNNING: Hi there
           \t  metadata:
           \t\t  (key: 'meta', value: 'data')
           \t\t  (key: 'data', value: 'meta')
-          \tTask:
+          \tTask role: bozo, env: test, name: woops, instance: 7734, status: RUNNING on slavehost
           \t  cpus: 2, ram: 2 MB, disk: 2 MB
           \t  events:
           \t   1970-11-23 ##:##:## RUNNING: Hi there
@@ -286,6 +289,7 @@ class TestJobStatus(AuroraClientCommandTest):
           \t\t  (key: 'data', value: 'meta')
           Inactive tasks (0):
           """)
+      print("=======actual======\n%s\n==================" % actual)
       assert actual == expected
 
   def test_successful_status_deep_null_metadata(self):
@@ -456,7 +460,7 @@ class TestJobStatus(AuroraClientCommandTest):
                     "numCpus": 2
                   },
                   "taskId": "task_1",
-                  "instanceId": 0,
+                  "instanceId": 1,
                   "assignedPorts": {
                     "http": 1001
                   },