Skip to content

Commit 3f97cbe

Browse files
committed
fix(ci): init.sh completion check should not be blocking
Add optional timeout parameter to run_ssh_command() to check init completion status with a 5-second timeout.
1 parent 3882f3e commit 3f97cbe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

testinfra/test_ami_nix.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def get_ssh_connection(instance_ip, ssh_identity_file, max_retries=10):
205205
sleep(5)
206206

207207

208-
def run_ssh_command(ssh, command):
208+
def run_ssh_command(ssh, command, timeout=None):
209209
"""Run a command over the established SSH connection."""
210-
stdin, stdout, stderr = ssh.exec_command(command)
210+
stdin, stdout, stderr = ssh.exec_command(command, timeout=timeout)
211211
exit_code = stdout.channel.recv_exit_status()
212212
return {
213213
'succeeded': exit_code == 0,
@@ -330,7 +330,7 @@ def gzip_then_base64_encode(s: str) -> str:
330330
attempt = 0
331331
while attempt < max_attempts:
332332
try:
333-
result = run_ssh_command(ssh, "test -f /var/lib/init-complete")
333+
result = run_ssh_command(ssh, "test -f /var/lib/init-complete", timeout=5)
334334
if result['succeeded']:
335335
logger.info("init.sh has completed")
336336
break

0 commit comments

Comments
 (0)