aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject aurora git commit: Ensure primary_port warning respects announcer portmap
Date Thu, 01 Feb 2018 09:20:45 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 858552db0 -> 21a371c4f


Ensure primary_port warning respects announcer portmap

This eliminates false-positive warnings in the client: It used to complain
about unbound primary ports if those where bound via the portmap.

Bugs closed: AURORA-1233

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


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

Branch: refs/heads/master
Commit: 21a371c4fc2972dadc1d0525c61558d525ceecad
Parents: 858552d
Author: Stephan Erb <serb@apache.org>
Authored: Wed Jan 31 21:25:57 2018 +0000
Committer: Stephan Erb <serb@apache.org>
Committed: Wed Jan 31 21:25:57 2018 +0000

----------------------------------------------------------------------
 src/main/python/apache/aurora/client/config.py  |  9 ++++----
 .../python/apache/aurora/client/test_config.py  | 24 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/21a371c4/src/main/python/apache/aurora/client/config.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/config.py b/src/main/python/apache/aurora/client/config.py
index adc8db0..c34a169 100644
--- a/src/main/python/apache/aurora/client/config.py
+++ b/src/main/python/apache/aurora/client/config.py
@@ -41,12 +41,13 @@ def _validate_announce_configuration(config):
     return
 
   primary_port = config.raw().announce().primary_port().get()
-  if primary_port not in config.ports():
+  portmap = config.raw().announce().portmap().get()
+
+  if primary_port not in config.ports() and primary_port not in portmap:
     print(ANNOUNCE_WARNING % {'primary_port': primary_port}, file=sys.stderr)
 
-  if config.raw().has_announce() and not config.raw().has_constraints() or (
-      'dedicated' not in config.raw().constraints()):
-    for port in config.raw().announce().portmap().get().values():
+  if not (config.raw().has_constraints() and 'dedicated' in config.raw().constraints()):
+    for port in portmap.values():
       try:
         port = int(port)
       except ValueError:

http://git-wip-us.apache.org/repos/asf/aurora/blob/21a371c4/src/test/python/apache/aurora/client/test_config.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/test_config.py b/src/test/python/apache/aurora/client/test_config.py
index 3d5289a..5e4e359 100644
--- a/src/test/python/apache/aurora/client/test_config.py
+++ b/src/test/python/apache/aurora/client/test_config.py
@@ -97,6 +97,30 @@ def test_get_config_with_broken_subscopes():
   assert 'Unexpected unbound refs' in str(cm.value.message)
 
 
+def test_get_config_primary_port_warning(capsys):
+  config_unbound_primary_port = MESOS_CONFIG_BASE % {
+    'cmdline': 'echo {{thermos.ports[http]}}',
+    'announce': 'announce = Announcer(primary_port = "custom", portmap = {}),'
+  }
+  get_aurora_config('hello_world', BytesIO(config_unbound_primary_port)).job()
+  _, err = capsys.readouterr()
+
+  msg = "Announcer specified primary port as 'custom' but no processes have bound that port"
+  assert msg in err
+
+
+def test_get_config_mapped_primary_port(capsys):
+  config_mapped_primary_port = MESOS_CONFIG_BASE % {
+    'cmdline': 'echo {{thermos.ports[custom]}}',
+    'announce': 'announce = Announcer(primary_port = "http", portmap = {"http": "custom"}),'
+  }
+  get_aurora_config('hello_world', BytesIO(config_mapped_primary_port)).job()
+  out, err = capsys.readouterr()
+
+  assert err == ""  # No warning about unbound primary port
+  assert out == ""
+
+
 def test_get_config_select():
   bio = BytesIO(MESOS_CONFIG_WITHOUT_ANNOUNCE)
 


Mime
View raw message