From 65790f34399241ff52f4cc5a557f7e8aa6897f60 Mon Sep 17 00:00:00 2001 From: Dmitry Meyer Date: Fri, 14 Nov 2025 15:07:56 +0000 Subject: [PATCH] Log non-zero exit status in SSHTunnel.close/aclose --- .../_internal/core/services/ssh/tunnel.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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(