From 1cf0040fd42a551819c5b190ad189100db4a5e28 Mon Sep 17 00:00:00 2001 From: Jvst Me Date: Mon, 30 Jun 2025 13:13:22 +0200 Subject: [PATCH] Support the local backend with the in-server proxy Fix this error when requesting a service running on the local backend and served by the in-server proxy: ```python File "/dstack/src/dstack/_internal/proxy/lib/services/service_connection.py", line 82, in open await self._tunnel.aopen() File "/dstack/src/dstack/_internal/core/services/ssh/tunnel.py", line 204, in aopen raise get_ssh_error(stderr) dstack._internal.core.errors.SSHError: Connection closed by UNKNOWN port 65535 ``` If the replica runs on the local backend, connect directly to the container, without proxy jumping through the shim host. Similar to workarounds in `SSHAttach` and `runner_ssh_tunnel`. --- src/dstack/_internal/server/services/proxy/repo.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dstack/_internal/server/services/proxy/repo.py b/src/dstack/_internal/server/services/proxy/repo.py index 1ec9a49ad0..4578cb56fb 100644 --- a/src/dstack/_internal/server/services/proxy/repo.py +++ b/src/dstack/_internal/server/services/proxy/repo.py @@ -7,6 +7,7 @@ import dstack._internal.server.services.jobs as jobs_services from dstack._internal.core.consts import DSTACK_RUNNER_SSH_PORT +from dstack._internal.core.models.backends.base import BackendType from dstack._internal.core.models.configurations import ServiceConfiguration from dstack._internal.core.models.instances import RemoteConnectionInfo, SSHConnectionParams from dstack._internal.core.models.runs import ( @@ -86,6 +87,8 @@ async def get_service(self, project_name: str, run_name: str) -> Optional[Servic username=jpd.username, port=jpd.ssh_port, ) + if jpd.backend == BackendType.LOCAL: + ssh_proxy = None ssh_head_proxy: Optional[SSHConnectionParams] = None ssh_head_proxy_private_key: Optional[str] = None instance = get_or_error(job.instance)