aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zma...@apache.org
Subject aurora git commit: Allow equals in bound variables passed via cmdline
Date Tue, 23 Jun 2015 00:01:35 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 3351b09b8 -> 2df2db951


Allow equals in bound variables passed via cmdline

The parsing for the --bind parameter splits the parameter value on equals and
enforces only two elements. This prevents parameters whose value contains an
equals to be passed.

Example case:
    HELLO_WORLD = Job(
         name = 'hello',
         role = 'bozo',
         cluster = 'west',
         environment = 'test',
         instances = 1,
         update_config = UpdateConfig(
           batch_size = 1,
           restart_threshold = 60,
           watch_secs = 45,
           max_per_shard_failures = 2,
         ),
         task = Task(
           name = 'test',
           processes = [Process(name = 'hello_world', cmdline = 'echo {{flags}}')],
           resources = Resources(cpu = 0.1, ram = 64 * MB, disk = 64 * MB),
         )
       )
       jobs = [HELLO_WORLD]

aurora job create --bind flags=-myflag=value west/bozo/test/hello ./hello_world.aurora

Instead, the split() should use the maxsplit parameter to limit to 1 match and
leave additional equals signs in the parameter

Testing Done:
Added a new binding to UNBOUND_CONFIG and a matching --bind parameter with an
equals sign in it to test_simple_successful_create_job_with_bindings
(test_create.py)

    $ ./pants test --test-pytest-options='-k _bindings' src/test/python/apache/aurora:all
passes

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


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

Branch: refs/heads/master
Commit: 2df2db951f5006be3da49eae431e830550378e26
Parents: 3351b09
Author: Michael Leinartas <mleinartas@gmail.com>
Authored: Mon Jun 22 16:48:50 2015 -0700
Committer: zmanji@apache.org <zmanji@twitter.com>
Committed: Mon Jun 22 16:48:50 2015 -0700

----------------------------------------------------------------------
 src/main/python/apache/aurora/client/cli/options.py     | 4 ++--
 src/test/python/apache/aurora/client/cli/test_create.py | 1 +
 src/test/python/apache/aurora/client/cli/util.py        | 5 ++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/2df2db95/src/main/python/apache/aurora/client/cli/options.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/options.py b/src/main/python/apache/aurora/client/cli/options.py
index f8ac252..41b13d6 100644
--- a/src/main/python/apache/aurora/client/cli/options.py
+++ b/src/main/python/apache/aurora/client/cli/options.py
@@ -147,8 +147,8 @@ def binding_parser(binding):
   the user from a list of "name=value" formatted strings to a list of the dictionaries
   expected by pystachio.
   """
-  binding_parts = binding.split("=")
-  if len(binding_parts) != 2:
+  binding_parts = binding.split("=", 1)
+  if len(binding_parts) < 2:
     raise ValueError('Binding parameter must be formatted name=value')
   try:
     ref = Ref.from_address(binding_parts[0])

http://git-wip-us.apache.org/repos/asf/aurora/blob/2df2db95/src/test/python/apache/aurora/client/cli/test_create.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_create.py b/src/test/python/apache/aurora/client/cli/test_create.py
index 9f32ca3..101a01d 100644
--- a/src/test/python/apache/aurora/client/cli/test_create.py
+++ b/src/test/python/apache/aurora/client/cli/test_create.py
@@ -374,6 +374,7 @@ class TestClientCreateCommand(AuroraClientCommandTest):
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'create', '--wait-until=RUNNING', '--bind', 'cluster_binding=west',
             '--bind', 'instances_binding=20', '--bind', 'TEST_BATCH=1',
+            '--bind', 'flags_binding=-some_flag=value',
             'west/bozo/test/hello',
             fp.name])
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/2df2db95/src/test/python/apache/aurora/client/cli/util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/util.py b/src/test/python/apache/aurora/client/cli/util.py
index 053c9a5..d7d8873 100644
--- a/src/test/python/apache/aurora/client/cli/util.py
+++ b/src/test/python/apache/aurora/client/cli/util.py
@@ -296,7 +296,10 @@ jobs = [HELLO_WORLD]
         ),
         task = Task(
           name = 'test',
-          processes = [Process(name = 'hello_world', cmdline = 'echo {{thermos.ports[http]}}')],
+          processes = [Process(
+            name = 'hello_world',
+            cmdline = 'echo {{thermos.ports[http]}} {{flags_binding}}'
+          )],
           resources = Resources(cpu = 0.1, ram = 64 * MB, disk = 64 * MB),
         )
       )


Mime
View raw message