Skip to content

Remove unused Docker-SDK port detection in tasks.py#641

Open
Valyrian-Code wants to merge 1 commit into
GeoNode:masterfrom
Valyrian-Code:fix/remove-container-exposed-port
Open

Remove unused Docker-SDK port detection in tasks.py#641
Valyrian-Code wants to merge 1 commit into
GeoNode:masterfrom
Valyrian-Code:fix/remove-container-exposed-port

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Fixes #627.

Background

e2c6309 removed the top-level import docker from src/tasks.py (and moved _docker_host_ip() off the Docker SDK), but _container_exposed_port() still called docker.from_env(...). With no import, that call raised NameError, which the function's try/except swallowed — printing a traceback and falling back to "80" — on every start where GEONODE_LB_PORT is unset.

As discussed in #627 (thanks @mattiagiupponi), the public port is sourced from GEONODE_LB_PORT, so the Docker-API detection isn't needed.

Change

  • Remove _container_exposed_port() entirely.
  • Simplify _geonode_public_port() to rely on GEONODE_LB_PORT.
  • Drop the now-unused import re (its only use was inside the removed function).

Behavior

Equivalent to before. Previously, when GEONODE_LB_PORT was unset, _container_exposed_port() returned "80", which update() then normalized to None (via if ... or pub_port == "80": pub_port = None). The simplified function returns None directly for unset / "80" / "443", and the explicit value otherwise — same end result.

Verification

  • python -m py_compile src/tasks.py passes.
  • No remaining references to docker., re., or _container_exposed_port in the module.

_container_exposed_port() called docker.from_env(), but 'import docker'
was dropped in e2c6309, so it raised NameError (caught, logged a traceback,
fell back to '80') on every start where GEONODE_LB_PORT is unset. The public
port is sourced from GEONODE_LB_PORT, so remove _container_exposed_port() and
simplify _geonode_public_port() to rely on it. Drop the now-unused import re.

Fixes GeoNode#627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tasks.py: _container_exposed_port() calls docker.from_env but 'import docker' was dropped in e2c6309

1 participant