Return-Path: X-Original-To: apmail-aurora-commits-archive@minotaur.apache.org Delivered-To: apmail-aurora-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D2FD110495 for ; Tue, 2 Dec 2014 21:32:50 +0000 (UTC) Received: (qmail 62224 invoked by uid 500); 2 Dec 2014 21:32:50 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 62189 invoked by uid 500); 2 Dec 2014 21:32:50 -0000 Mailing-List: contact commits-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list commits@aurora.incubator.apache.org Received: (qmail 62180 invoked by uid 99); 2 Dec 2014 21:32:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Dec 2014 21:32:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 02 Dec 2014 21:32:49 +0000 Received: (qmail 62077 invoked by uid 99); 2 Dec 2014 21:32:29 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Dec 2014 21:32:29 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 12DE99BC2FD; Tue, 2 Dec 2014 21:32:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kevints@apache.org To: commits@aurora.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-aurora git commit: Improve unbounded ref exception. Date: Tue, 2 Dec 2014 21:32:29 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org 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 Authored: Tue Dec 2 13:32:21 2014 -0800 Committer: Kevin Sweeney 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}}"