Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove edge port config #9636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions localstack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
)


Expand All @@ -647,8 +643,6 @@ def populate_edge_configuration(
# Main configuration of the listen address of the hypercorn proxy. Of the form
# <ip_address>:<port>(,<ip_address>:port>)*
GATEWAY_LISTEN,
# -- Legacy variables
EDGE_PORT,
) = populate_edge_configuration(os.environ)

# IP of the docker bridge used to enable access between containers
Expand Down
2 changes: 1 addition & 1 deletion localstack/utils/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/integration/utils/test_diagnose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:
Expand Down