diff --git a/src/paude/backends/openshift/session_connection.py b/src/paude/backends/openshift/session_connection.py index 9e5b6d1..3e4afd5 100644 --- a/src/paude/backends/openshift/session_connection.py +++ b/src/paude/backends/openshift/session_connection.py @@ -339,8 +339,10 @@ def _build_exec_cmd( else: cmd = ["oc", "exec", "-it", "-n", ns, pname, "--"] + env_args = ["env", "PAUDE_HEADLESS=0"] if port_urls: - cmd.extend(["env", f"PAUDE_PORT_URLS={';'.join(port_urls)}"]) + env_args.append(f"PAUDE_PORT_URLS={';'.join(port_urls)}") + cmd.extend(env_args) cmd.append("/usr/local/bin/entrypoint-session.sh") return cmd diff --git a/tests/test_openshift_backend.py b/tests/test_openshift_backend.py index 0431d3d..bc6d45c 100644 --- a/tests/test_openshift_backend.py +++ b/tests/test_openshift_backend.py @@ -1076,7 +1076,7 @@ def _make_connector(self, context: str | None = None) -> Any: ) def test_exec_cmd_without_port_urls(self) -> None: - """Exec command has no env prefix when no port URLs.""" + """Exec command overrides PAUDE_HEADLESS even without port URLs.""" connector = self._make_connector() cmd = connector._build_exec_cmd("pod-0", "test-ns") assert cmd == [ @@ -1087,6 +1087,8 @@ def test_exec_cmd_without_port_urls(self) -> None: "test-ns", "pod-0", "--", + "env", + "PAUDE_HEADLESS=0", "/usr/local/bin/entrypoint-session.sh", ] @@ -1099,6 +1101,7 @@ def test_exec_cmd_with_port_urls(self) -> None: port_urls=["http://localhost:18789"], ) assert "env" in cmd + assert "PAUDE_HEADLESS=0" in cmd assert "PAUDE_PORT_URLS=http://localhost:18789" in cmd # env and PAUDE_PORT_URLS must come before entrypoint env_idx = cmd.index("env") @@ -1113,6 +1116,7 @@ def test_exec_cmd_with_multiple_port_urls(self) -> None: "test-ns", port_urls=["http://localhost:8080", "http://localhost:8443"], ) + assert "PAUDE_HEADLESS=0" in cmd env_val = [c for c in cmd if c.startswith("PAUDE_PORT_URLS=")][0] assert env_val == ( "PAUDE_PORT_URLS=http://localhost:8080;http://localhost:8443" @@ -1128,6 +1132,7 @@ def test_exec_cmd_with_context_and_port_urls(self) -> None: ) assert cmd[:4] == ["oc", "--context", "my-ctx", "exec"] assert "env" in cmd + assert "PAUDE_HEADLESS=0" in cmd assert "PAUDE_PORT_URLS=http://localhost:18789" in cmd