Skip to content

Commit 5b8e44a

Browse files
Manciukicroypat
authored andcommitted
fix(test): do not use absolute path to true when opening ssh connection
In #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]>
1 parent 5c3ff08 commit 5b8e44a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/host_tools/network.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ def _init_connection(self):
129129
"ControlPersist=yes",
130130
*self.options,
131131
self.user_host,
132-
"/usr/bin/true",
132+
"true",
133133
]
134134

135-
# don't set a low timeout here, because otherwise we might get into a race condition
136-
# where ssh already forked off the persisted connection daemon, but gets killed here
137-
# before exiting itself. In that case, self._control_path will exist, and the retry
138-
# will hit the assert at the start of this function.
139-
self._exec(establish_cmd, check=True)
135+
try:
136+
# don't set a low timeout here, because otherwise we might get into a race condition
137+
# where ssh already forked off the persisted connection daemon, but gets killed here
138+
# before exiting itself. In that case, self._control_path will exist, and the retry
139+
# will hit the assert at the start of this function.
140+
self._exec(establish_cmd, check=True)
141+
except Exception:
142+
# if the control socket is present, then the daemon is running, and we should stop it
143+
# before retrying again
144+
if self._control_path.exists():
145+
self.close()
146+
raise
140147

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

0 commit comments

Comments
 (0)