From d4cd7027d828e2d144ad67a1c92223ddcbfe5d35 Mon Sep 17 00:00:00 2001 From: Joel Scheuner Date: Tue, 14 Nov 2023 23:46:44 +0100 Subject: [PATCH 1/2] Ignore EDGE_PORT environment variable in localstack validation --- localstack/utils/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localstack/utils/bootstrap.py b/localstack/utils/bootstrap.py index 8b2698107acd8..d0079cacf0d1b 100644 --- a/localstack/utils/bootstrap.py +++ b/localstack/utils/bootstrap.py @@ -359,7 +359,7 @@ def validate_localstack_config(name: str): docker_env = dict( (env.split("=")[0], env.split("=")[1]) for env in ls_service_details.get("environment", {}) ) - edge_port = str(docker_env.get("EDGE_PORT") or config.GATEWAY_LISTEN[0].port) + edge_port = config.GATEWAY_LISTEN[0].port main_container = config.MAIN_CONTAINER_NAME # docker-compose file validation cases From 086b121ffe250388e67f49d785b4979a74b9d059 Mon Sep 17 00:00:00 2001 From: Joel Scheuner Date: Tue, 14 Nov 2023 23:55:11 +0100 Subject: [PATCH 2/2] Remove legacy variable config.EDGE_PORT --- localstack/config.py | 8 +------- tests/integration/utils/test_diagnose.py | 1 - tests/unit/test_config.py | 10 ++-------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/localstack/config.py b/localstack/config.py index 9397cff1cc629..4bc1dcb8945ff 100644 --- a/localstack/config.py +++ b/localstack/config.py @@ -594,7 +594,7 @@ def append(self, value: HostAndPort): def populate_edge_configuration( environment: Mapping[str, str] -) -> Tuple[HostAndPort, UniqueHostAndPortList, int]: +) -> Tuple[HostAndPort, UniqueHostAndPortList]: """Populate the LocalStack edge configuration from environment variables.""" localstack_host_raw = environment.get("LOCALSTACK_HOST") gateway_listen_raw = environment.get("GATEWAY_LISTEN") @@ -629,13 +629,9 @@ def populate_edge_configuration( assert gateway_listen is not None assert localstack_host is not None - # derive legacy variables from GATEWAY_LISTEN - edge_port = gateway_listen[0].port - return ( localstack_host, UniqueHostAndPortList(gateway_listen), - edge_port, ) @@ -647,8 +643,6 @@ def populate_edge_configuration( # Main configuration of the listen address of the hypercorn proxy. Of the form # :(,:port>)* GATEWAY_LISTEN, - # -- Legacy variables - EDGE_PORT, ) = populate_edge_configuration(os.environ) # IP of the docker bridge used to enable access between containers diff --git a/tests/integration/utils/test_diagnose.py b/tests/integration/utils/test_diagnose.py index f0e5f5b30f29f..3162f5710c316 100644 --- a/tests/integration/utils/test_diagnose.py +++ b/tests/integration/utils/test_diagnose.py @@ -10,7 +10,6 @@ def test_diagnose_resource(): assert "/tmp" in result["file-tree"] assert "/var/lib/localstack" in result["file-tree"] - assert result["config"]["EDGE_PORT"] == config.EDGE_PORT assert result["config"]["DATA_DIR"] == config.DATA_DIR assert result["config"]["GATEWAY_LISTEN"] == [config.HostAndPort("0.0.0.0", 4566)] assert result["important-endpoints"]["localhost.localstack.cloud"].startswith("127.0.") diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index a648651234ba5..9bcffa3c05e16 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -138,30 +138,26 @@ def test_edge_configuration( ( actual_ls_host, actual_gateway_listen, - actual_edge_port, ) = config.populate_edge_configuration(environment) assert actual_ls_host == expected_localstack_host assert actual_gateway_listen == expected_gateway_listen - assert actual_edge_port == expected_edge_port def test_gateway_listen_multiple_addresses(self): environment = {"GATEWAY_LISTEN": "0.0.0.0:9999,0.0.0.0:443"} ( _, gateway_listen, - edge_port, ) = config.populate_edge_configuration(environment) assert gateway_listen == [ HostAndPort(host="0.0.0.0", port=9999), HostAndPort(host="0.0.0.0", port=443), ] - # take the first value - assert edge_port == 9999 def test_legacy_variables_ignored_if_given(self): - """Providing legacy variables removed in 3.0 should not affect the default configuration""" + """Providing legacy variables removed in 3.0 should not affect the default configuration. + This test can be removed around >3.1-4.0.""" environment = { "EDGE_BIND_HOST": "192.168.0.1", "EDGE_PORT": "10101", @@ -170,14 +166,12 @@ def test_legacy_variables_ignored_if_given(self): ( localstack_host, gateway_listen, - edge_port, ) = config.populate_edge_configuration(environment) assert localstack_host == "localhost.localstack.cloud:4566" assert gateway_listen == [ HostAndPort(host=ip(), port=4566), ] - assert edge_port == 4566 class TestUniquePortList: