From 12548bcab3bb760e38c269bc1ff9b33611ac2985 Mon Sep 17 00:00:00 2001 From: Hogne <227774406+hognek@users.noreply.github.com> Date: Sat, 18 Jul 2026 01:00:34 +0200 Subject: [PATCH 1/3] fix(install): route LXC port allocation through centralized allocator Replace the standalone _find_free_port() in lxc_installer.py with allocate_host_port(app_id) from port_allocator.py so the centralized allocator is the single source of truth for all app host-port assignments. - Remove _find_free_port(), socket, and closing imports from lxc_installer - Import allocate_host_port instead of RESERVED_PORTS - Accumulate failed ports in exclude set across TOCTOU retry loop - Fix stale _docker_published_port docstring (DockerInstaller now maps {allocated_host_port}:{container_port}, not {p}:{p}) - Add test class verifying _find_free_port is gone and allocate_host_port is the only import Refs: #695 --- tests/installers/test_port_allocator.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/installers/test_port_allocator.py b/tests/installers/test_port_allocator.py index fb9e31a2d..cd62635fb 100644 --- a/tests/installers/test_port_allocator.py +++ b/tests/installers/test_port_allocator.py @@ -124,9 +124,6 @@ def test_allocate_host_port_imported(self): assert hasattr(mod, "allocate_host_port"), ( "lxc_installer must import allocate_host_port" ) - assert not hasattr(mod, "RESERVED_PORTS"), ( - "lxc_installer must not import RESERVED_PORTS; allocate_host_port handles that internally" - ) def test_installer_class_available(self): """LXCInstaller is importable (sanity check — no import errors from the refactor).""" From 46073508e98b44a9c464a13155e1d87152c73ec1 Mon Sep 17 00:00:00 2001 From: Hogne <227774406+hognek@users.noreply.github.com> Date: Sat, 18 Jul 2026 01:04:36 +0200 Subject: [PATCH 2/3] test: strengthen allocator import assertion per Kilo suggestion Add assert not hasattr(mod, 'RESERVED_PORTS') to verify the old import is truly removed, not just that allocate_host_port is present. --- tests/installers/test_port_allocator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/installers/test_port_allocator.py b/tests/installers/test_port_allocator.py index cd62635fb..fb9e31a2d 100644 --- a/tests/installers/test_port_allocator.py +++ b/tests/installers/test_port_allocator.py @@ -124,6 +124,9 @@ def test_allocate_host_port_imported(self): assert hasattr(mod, "allocate_host_port"), ( "lxc_installer must import allocate_host_port" ) + assert not hasattr(mod, "RESERVED_PORTS"), ( + "lxc_installer must not import RESERVED_PORTS; allocate_host_port handles that internally" + ) def test_installer_class_available(self): """LXCInstaller is importable (sanity check — no import errors from the refactor).""" From dc1c8ae5750c423e31b520839ac2eb35e242dfd0 Mon Sep 17 00:00:00 2001 From: Hogne <227774406+hognek@users.noreply.github.com> Date: Sat, 18 Jul 2026 10:09:10 +0200 Subject: [PATCH 3/3] test: replace always-true assert with issubclass check in test_installer_class_available --- tests/installers/test_port_allocator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/installers/test_port_allocator.py b/tests/installers/test_port_allocator.py index fb9e31a2d..56d2f917b 100644 --- a/tests/installers/test_port_allocator.py +++ b/tests/installers/test_port_allocator.py @@ -1,6 +1,7 @@ """Tests for host-port allocation: every handed-out port is probed free.""" import socket +from tinyagentos.installers.base import AppInstaller from tinyagentos.installers.docker_installer import DockerInstaller from tinyagentos.installers.lxc_installer import LXCInstaller from tinyagentos.installers.port_allocator import ( @@ -129,5 +130,5 @@ def test_allocate_host_port_imported(self): ) def test_installer_class_available(self): - """LXCInstaller is importable (sanity check — no import errors from the refactor).""" - assert LXCInstaller is not None + """LXCInstaller is a proper AppInstaller subclass (class hierarchy regression check).""" + assert issubclass(LXCInstaller, AppInstaller)