From 72f98fabd4f5506cb5f2f8c0a59cbcf5af7a478f Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 26 Sep 2024 19:40:28 +0200 Subject: [PATCH] fixup! WIP XS 6.5 --- lib/commands.py | 8 ++++---- lib/installer.py | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/commands.py b/lib/commands.py index 78891fbd6..40f8634e3 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -112,9 +112,9 @@ def _ssh(hostname_or_ip, cmd, check, simple_output, suppress_fingerprint_warning # Get a decoded version of the output in any case, replacing potential errors output_for_errors = res.stdout.decode(errors='replace').strip() - # Even if check is False, we still raise in case of return code 255, which means a SSH error. - if res.returncode == 255: - return False, SSHCommandFailed(255, "SSH Error: %s" % output_for_errors, command) +# # Even if check is False, we still raise in case of return code 255, which means a SSH error. +# if res.returncode == 255: +# return False, SSHCommandFailed(255, "SSH Error: %s" % output_for_errors, command) output = res.stdout if config.ignore_ssh_banner: @@ -125,7 +125,7 @@ def _ssh(hostname_or_ip, cmd, check, simple_output, suppress_fingerprint_warning if decode: output = output.decode() - if res.returncode and check: + if res.returncode not in (0, 255) and check: return False, SSHCommandFailed(res.returncode, output_for_errors, command) if simple_output: diff --git a/lib/installer.py b/lib/installer.py index 6c9b6f8ce..253849e20 100644 --- a/lib/installer.py +++ b/lib/installer.py @@ -68,33 +68,35 @@ def _defn_to_xml_et(defn, /, *, parent=None): def poweroff(ip): try: - ssh(ip, ["poweroff"], options=SSHOPTS) + ssh(ip, ["/sbin/poweroff"], options=SSHOPTS) except SSHCommandFailed as e: # ignore connection closed by reboot if e.returncode == 255 and "closed by remote host" in e.stdout: logging.info("sshd closed the connection") pass + elif e.returncode == 255: + logging.info("sshd misbehaving?") else: raise def monitor_install(*, ip): # wait for "yum install" phase to finish - wait_for(lambda: ssh(ip, ["grep", + wait_for(lambda: "DISPATCH: NEW PHASE: Completing installation" in ssh(ip, ["grep", "'DISPATCH: NEW PHASE: Completing installation'", "/tmp/install-log"], check=False, simple_output=False, options=SSHOPTS, - ).returncode == 0, + ).stdout, "Wait for rpm installation to succeed", timeout_secs=40 * 60) # FIXME too big # wait for install to finish - wait_for(lambda: ssh(ip, ["grep", + wait_for(lambda: "The installation completed successfully" in ssh(ip, ["grep", "'The installation completed successfully'", "/tmp/install-log"], check=False, simple_output=False, options=SSHOPTS, - ).returncode == 0, + ).stdout, "Wait for system installation to succeed", timeout_secs=40 * 60) # FIXME too big