You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ke...@apache.org on 2014/12/02 22:32:29 UTC

incubator-aurora git commit: Improve unbounded ref exception.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master dc666e7e4 -> c86ca6d88


Improve unbounded ref exception.

This improves the contents of the exception that is raised when the
executor is given a TaskConfig with unbounded refs.

Testing Done:
./pants src/test/python/apache/aurora/executor/common:task_info

Bugs closed: AURORA-939

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


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

Branch: refs/heads/master
Commit: c86ca6d881c03f7b32135cb24837cb1d0bf30464
Parents: dc666e7
Author: Zameer Manji <zm...@twopensource.com>
Authored: Tue Dec 2 13:32:21 2014 -0800
Committer: Kevin Sweeney <ke...@apache.org>
Committed: Tue Dec 2 13:32:21 2014 -0800

----------------------------------------------------------------------
 .../apache/aurora/executor/common/task_info.py       |  8 +++++++-
 .../python/apache/aurora/executor/common/fixtures.py |  4 ++++
 .../apache/aurora/executor/common/test_task_info.py  | 15 ++++++++++++++-
 3 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c86ca6d8/src/main/python/apache/aurora/executor/common/task_info.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/common/task_info.py b/src/main/python/apache/aurora/executor/common/task_info.py
index 88ebdad..d110faf 100644
--- a/src/main/python/apache/aurora/executor/common/task_info.py
+++ b/src/main/python/apache/aurora/executor/common/task_info.py
@@ -69,6 +69,7 @@ def mesos_task_instance_from_assigned_task(assigned_task):
 
   # This is a MesosJob
   mti, refs = task_instance_from_job(MesosJob.json_loads(thermos_task), assigned_task.instanceId)
+  unbound_refs = []
   for ref in refs:
     # If the ref is {{thermos.task_id}} or a subscope of
     # {{thermos.ports}}, it currently gets bound by the Thermos Runner,
@@ -85,7 +86,12 @@ def mesos_task_instance_from_assigned_task(assigned_task):
       continue
     if ref == Ref.from_address('thermos.user'):
       continue
-    raise ValueError('Unexpected unbound refs: %s' % ' '.join(map(str, refs)))
+    else:
+      unbound_refs.append(ref)
+
+  if len(unbound_refs) != 0:
+    raise ValueError('Unexpected unbound refs: %s' % ' '.join(map(str, unbound_refs)))
+
   return mti
 
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c86ca6d8/src/test/python/apache/aurora/executor/common/fixtures.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/common/fixtures.py b/src/test/python/apache/aurora/executor/common/fixtures.py
index 55d7358..37d032b 100644
--- a/src/test/python/apache/aurora/executor/common/fixtures.py
+++ b/src/test/python/apache/aurora/executor/common/fixtures.py
@@ -41,3 +41,7 @@ MESOS_JOB = MesosJob(
   instances=1,
   role=getpass.getuser(),
 )
+
+HELLO_WORLD_UNBOUND = BASE_TASK(
+    name='{{unbound_cmd}}',
+    processes=[Process(name='hello_world_{{thermos.task_id}}', cmdline='echo hello {{unbound}}')])

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c86ca6d8/src/test/python/apache/aurora/executor/common/test_task_info.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/common/test_task_info.py b/src/test/python/apache/aurora/executor/common/test_task_info.py
index 8f71717..102ba53 100644
--- a/src/test/python/apache/aurora/executor/common/test_task_info.py
+++ b/src/test/python/apache/aurora/executor/common/test_task_info.py
@@ -12,9 +12,11 @@
 # limitations under the License.
 #
 
+import pytest
+
 from apache.aurora.executor.common.task_info import mesos_task_instance_from_assigned_task
 
-from .fixtures import BASE_MTI, HELLO_WORLD, HELLO_WORLD_MTI, MESOS_JOB
+from .fixtures import BASE_MTI, HELLO_WORLD, HELLO_WORLD_MTI, HELLO_WORLD_UNBOUND, MESOS_JOB
 
 from gen.apache.aurora.api.ttypes import AssignedTask, ExecutorConfig, TaskConfig
 
@@ -29,3 +31,14 @@ def test_deserialize_thermos_task():
     executorConfig=ExecutorConfig(name='thermos', data=HELLO_WORLD_MTI.json_dumps()))
   assigned_task = AssignedTask(task=task_config, instanceId=0)
   assert mesos_task_instance_from_assigned_task(assigned_task) == BASE_MTI(task=HELLO_WORLD)
+
+
+def test_deserialize_thermos_task_unbound_refs():
+  task_config = TaskConfig(
+      executorConfig=ExecutorConfig(
+        name='thermos', data=MESOS_JOB(task=HELLO_WORLD_UNBOUND).json_dumps()))
+  assigned_task = AssignedTask(task=task_config, instanceId=0)
+  with pytest.raises(ValueError) as execinfo:
+    mesos_task_instance_from_assigned_task(assigned_task)
+
+  assert execinfo.value.message == "Unexpected unbound refs: {{unbound_cmd}} {{unbound}}"