<#3450 fix(interactive): pin PORT env var so code-...
# flyte-github
a
#3450 fix(interactive): pin PORT env var so code-server binds to the correct port Pull request opened by jeevb Problem When the pod/image has a
PORT
environment variable set (common in Kubernetes), the
code-server
subprocess binds to the wrong port despite being launched with
--bind-addr 0.0.0.0:{self.port}
. Root cause
code-server
reads the
PORT
environment variable as one of its bind-address sources.
execute_command
launches the subprocess via
subprocess.Popen(cmd, shell=True, ...)
, which inherits the parent process's full environment — so an inherited
PORT
overrides the explicit
--bind-addr
flag. Fix •
execute_command
now accepts an optional
env
dict, merged on top of
os.environ
(preserving other inherited vars) and passed to
Popen(..., env=...)
. • The
vscode
decorator passes
env={"PORT": str(self.port)}
to the code-server subprocess, pinning
PORT
so an inherited value can't override
--bind-addr
. Tests •
test_vscode_passes_port_env_to_child_process
— asserts the child process receives
env={"PORT": "1234"}
even when the surrounding environment has
PORT=9999
. •
test_execute_command_passes_env_to_subprocess
— asserts the override reaches
Popen
while other inherited vars survive. All 19 interactive unit tests pass. flyteorg/flytekit