Skip to content

Commit a172672

Browse files
authored
Log non-zero exit status in SSHTunnel.close/aclose (#3296)
1 parent 1fb486e commit a172672

File tree

1 file changed

+16
-2
lines changed
  • src/dstack/_internal/core/services/ssh

1 file changed

+16
-2
lines changed

src/dstack/_internal/core/services/ssh/tunnel.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,27 @@ async def aopen(self) -> None:
204204
raise get_ssh_error(stderr)
205205

206206
def close(self) -> None:
207-
subprocess.run(self.close_command(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
207+
proc = subprocess.run(
208+
self.close_command(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT
209+
)
210+
if proc.returncode:
211+
logger.error(
212+
"Failed to close SSH tunnel, exit status: %d, output: %s",
213+
proc.returncode,
214+
proc.stdout,
215+
)
208216

209217
async def aclose(self) -> None:
210218
proc = await asyncio.create_subprocess_exec(
211-
*self.close_command(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
219+
*self.close_command(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT
212220
)
213221
await proc.wait()
222+
if proc.returncode:
223+
logger.error(
224+
"Failed to close SSH tunnel, exit status: %d, output: %s",
225+
proc.returncode,
226+
proc.stdout,
227+
)
214228

215229
async def acheck(self) -> bool:
216230
proc = await asyncio.create_subprocess_exec(

0 commit comments

Comments
 (0)