Skip to content

Commit

Permalink
fix(test): do not use absolute path to true when opening ssh connection
Browse files Browse the repository at this point in the history
In firecracker-microvm#4955 the executable to check the ssh connection liveliness was
changed from `true` to `/usr/bin/true`, but that is not its path in all
rootfs, causing failures in the `test-populat-containers` suite.

Also, since the error is retried but the daemon is not cleaned
up, subsequent retries would fail for the assertion.

This change fixes both issues by using the binary name `true` and
stopping the daemon on error before the next retry.

Fixes: 3b2c2d4 ("test: use single SSH connection for lifetime of microvm")
Signed-off-by: Riccardo Mancini <[email protected]>
  • Loading branch information
Manciukic committed Dec 16, 2024
1 parent 0bee970 commit 112f6d3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/host_tools/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,19 @@ def _init_connection(self):
"ControlPersist=yes",
*self.options,
self.user_host,
"/usr/bin/true",
"true",
]

# don't set a low timeout here, because otherwise we might get into a race condition
# where ssh already forked off the persisted connection daemon, but gets killed here
# before exiting itself. In that case, self._control_path will exist, and the retry
# will hit the assert at the start of this function.
self._exec(establish_cmd, check=True)
try:
# don't set a low timeout here, because otherwise we might get into a race condition
# where ssh already forked off the persisted connection daemon, but gets killed here
# before exiting itself. In that case, self._control_path will exist, and the retry
# will hit the assert at the start of this function.
self._exec(establish_cmd, check=True)
except Exception:
# cleanup the control socket to allow for retries
self.close()
raise

def _check_liveness(self) -> int:
"""Checks whether the ControlPersist connection is still alive"""
Expand Down

0 comments on commit 112f6d3

Please sign in to comment.