Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "sshdriver: Prevent timeout from deadlock" #1288

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions labgrid/driver/sshdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def _start_own_master_once(self, timeout):

try:
subprocess_timeout = timeout + 5
stdout, _ = self.process.communicate(timeout=subprocess_timeout)
if self.process.returncode != 0:
return_value = self.process.wait(timeout=subprocess_timeout)
if return_value != 0:
stdout, _ = self.process.communicate(timeout=subprocess_timeout)
stdout = stdout.split(b"\n")
for line in stdout:
self.logger.warning("ssh: %s", line.rstrip().decode(encoding="utf-8", errors="replace"))
Expand All @@ -156,14 +157,12 @@ def _start_own_master_once(self, timeout):
pass

raise ExecutionError(
f"Failed to connect to {self.networkservice.address} with {' '.join(args)}: return code {self.process.returncode}", # pylint: disable=line-too-long
f"Failed to connect to {self.networkservice.address} with {' '.join(args)}: return code {return_value}", # pylint: disable=line-too-long
stdout=stdout,
)
except subprocess.TimeoutExpired:
self.process.kill()
stdout, _ = self.process.communicate()
raise ExecutionError(
f"Subprocess timed out [{subprocess_timeout}s] while executing {args}: {stdout}",
f"Subprocess timed out [{subprocess_timeout}s] while executing {args}",
)
finally:
if self.networkservice.password and os.path.exists(pass_file):
Expand Down
4 changes: 0 additions & 4 deletions tests/test_sshdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def ssh_driver_mocked_and_activated(target, mocker):
instance_mock = mocker.MagicMock()
popen.return_value = instance_mock
instance_mock.wait = mocker.MagicMock(return_value=0)
instance_mock.communicate = mocker.MagicMock(return_value=(b"", b""))
instance_mock.returncode = 0
SSHDriver(target, "ssh")
s = target.get_driver("SSHDriver")
return s
Expand All @@ -37,8 +35,6 @@ def test_create(target, mocker):
instance_mock = mocker.MagicMock()
popen.return_value = instance_mock
instance_mock.wait = mocker.MagicMock(return_value=0)
instance_mock.communicate = mocker.MagicMock(return_value=(b"", b""))
instance_mock.returncode = 0
s = SSHDriver(target, "ssh")
assert isinstance(s, SSHDriver)

Expand Down