Skip to content

Commit e25142a

Browse files
ethanwharristchaton
authored andcommitted
[App] Reserve APP_SERVER_PORT in cloud port allocation (#16782)
Co-authored-by: thomas chaton <[email protected]>
1 parent 1fea9d0 commit e25142a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/lightning_app/utilities/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def find_free_network_port() -> int:
6868
def _find_free_network_port_cloudspace():
6969
"""Finds a free port in the exposed range when running in a cloudspace."""
7070
for port in range(
71-
constants.APP_SERVER_PORT,
71+
constants.APP_SERVER_PORT + 1, # constants.APP_SERVER_PORT is reserved for the app server
7272
constants.APP_SERVER_PORT + constants.LIGHTNING_CLOUDSPACE_EXPOSED_PORT_COUNT,
7373
):
7474
if port in _reserved_ports:

tests/tests_app/utilities/test_network.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44

5+
from lightning_app.core import constants
56
from lightning_app.utilities.network import find_free_network_port, LightningClient
67

78

@@ -40,6 +41,9 @@ def test_find_free_network_port_cloudspace(_, patch_constants):
4041
# Check that all ports are unique
4142
assert len(ports) == num_ports
4243

44+
# Shouldn't use the APP_SERVER_PORT
45+
assert constants.APP_SERVER_PORT not in ports
46+
4347

4448
def test_lightning_client_retry_enabled():
4549

0 commit comments

Comments
 (0)