Skip to content

Commit

Permalink
Merge pull request #1266 from JoshuaWatt/log-keepalive-output
Browse files Browse the repository at this point in the history
sshdriver: Log keepalive output
  • Loading branch information
Emantor authored Oct 5, 2023
2 parents fc3afcb + d08a35c commit d8adccd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions labgrid/driver/sshdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ def _start_keepalive(self):
args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding="utf-8",
)

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

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

stdout = None
try:
self._keepalive.communicate(timeout=60)
stdout, _ = self._keepalive.communicate(timeout=60)
except subprocess.TimeoutExpired:
self._keepalive.kill()

try:
self._keepalive.wait(timeout=60)
try:
# Try again to get output
stdout, _ = self._keepalive.communicate(timeout=60)
except subprocess.TimeoutExpired:
self.logger.warning("ssh keepalive for %s timed out during termination", self.networkservice.address)
finally:
self._keepalive = None

if stdout:
for line in stdout.splitlines():
self.logger.warning("Keepalive %s: %s", self.networkservice.address, line)

0 comments on commit d8adccd

Please sign in to comment.