Skip to content

Commit d8adccd

Browse files
authored
Merge pull request #1266 from JoshuaWatt/log-keepalive-output
sshdriver: Log keepalive output
2 parents fc3afcb + d08a35c commit d8adccd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

labgrid/driver/sshdriver.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ def _start_keepalive(self):
527527
args,
528528
stdin=subprocess.PIPE,
529529
stdout=subprocess.PIPE,
530-
stderr=subprocess.PIPE,
530+
stderr=subprocess.STDOUT,
531+
encoding="utf-8",
531532
)
532533

533534
self.logger.debug('Started keepalive for %s', self.networkservice.address)
@@ -540,12 +541,19 @@ def _stop_keepalive(self):
540541

541542
self.logger.debug('Stopping keepalive for %s', self.networkservice.address)
542543

544+
stdout = None
543545
try:
544-
self._keepalive.communicate(timeout=60)
546+
stdout, _ = self._keepalive.communicate(timeout=60)
545547
except subprocess.TimeoutExpired:
546548
self._keepalive.kill()
547-
548-
try:
549-
self._keepalive.wait(timeout=60)
549+
try:
550+
# Try again to get output
551+
stdout, _ = self._keepalive.communicate(timeout=60)
552+
except subprocess.TimeoutExpired:
553+
self.logger.warning("ssh keepalive for %s timed out during termination", self.networkservice.address)
550554
finally:
551555
self._keepalive = None
556+
557+
if stdout:
558+
for line in stdout.splitlines():
559+
self.logger.warning("Keepalive %s: %s", self.networkservice.address, line)

0 commit comments

Comments
 (0)