Skip to content

Commit fbbe76b

Browse files
committed
contest: hw: mctrl: make sure SSH is alive before we reboot over it
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f386313 commit fbbe76b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

contest/hw/lib/reservations.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ def _finish_close(self, reservation_id, machine_ids):
170170
def _ssh_reboot(ipaddr):
171171
"""Try to reboot a machine via SSH. Returns True on success."""
172172
try:
173+
# Probe if SSH is responsive before issuing reboot
174+
ret = subprocess.run(
175+
['ssh', '-o', 'ConnectTimeout=5',
176+
'-o', 'StrictHostKeyChecking=no',
177+
'-o', 'BatchMode=yes',
178+
f'root@{ipaddr}', 'true'],
179+
capture_output=True, timeout=10, check=False
180+
)
181+
if ret.returncode != 0:
182+
return False
173183
subprocess.run(
174184
['ssh', '-o', 'ConnectTimeout=5',
175185
'-o', 'StrictHostKeyChecking=no',

0 commit comments

Comments
 (0)