diff --git a/src/dstack/_internal/core/services/ssh/tunnel.py b/src/dstack/_internal/core/services/ssh/tunnel.py index ef36257f6..abdb2ba52 100644 --- a/src/dstack/_internal/core/services/ssh/tunnel.py +++ b/src/dstack/_internal/core/services/ssh/tunnel.py @@ -204,13 +204,27 @@ async def aopen(self) -> None: raise get_ssh_error(stderr) def close(self) -> None: - subprocess.run(self.close_command(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + proc = subprocess.run( + self.close_command(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT + ) + if proc.returncode: + logger.error( + "Failed to close SSH tunnel, exit status: %d, output: %s", + proc.returncode, + proc.stdout, + ) async def aclose(self) -> None: proc = await asyncio.create_subprocess_exec( - *self.close_command(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + *self.close_command(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) await proc.wait() + if proc.returncode: + logger.error( + "Failed to close SSH tunnel, exit status: %d, output: %s", + proc.returncode, + proc.stdout, + ) async def acheck(self) -> bool: proc = await asyncio.create_subprocess_exec(