Remove unused Docker-SDK port detection in tasks.py#641
Open
Valyrian-Code wants to merge 1 commit into
Open
Conversation
_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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #627.
Background
e2c6309removed the top-levelimport dockerfromsrc/tasks.py(and moved_docker_host_ip()off the Docker SDK), but_container_exposed_port()still calleddocker.from_env(...). With no import, that call raisedNameError, which the function'stry/exceptswallowed — printing a traceback and falling back to"80"— on every start whereGEONODE_LB_PORTis 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
_container_exposed_port()entirely._geonode_public_port()to rely onGEONODE_LB_PORT.import re(its only use was inside the removed function).Behavior
Equivalent to before. Previously, when
GEONODE_LB_PORTwas unset,_container_exposed_port()returned"80", whichupdate()then normalized toNone(viaif ... or pub_port == "80": pub_port = None). The simplified function returnsNonedirectly for unset /"80"/"443", and the explicit value otherwise — same end result.Verification
python -m py_compile src/tasks.pypasses.docker.,re., or_container_exposed_portin the module.