Skip to content

Commit

Permalink
Dev: scripts: generate readable messages when ssh authentication fail…
Browse files Browse the repository at this point in the history
…s (bsc#1228899)
  • Loading branch information
nicholasyang2022 committed Sep 14, 2024
1 parent 04b7092 commit ae323cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion crmsh/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,13 @@ def _copy_utils(dst):
raise ValueError(e)


def _check_parallax_remote_available(printer, hosts):
try:
_parallax_call(printer, hosts, 'true', timeout_seconds=15)
except utils.UserOfHost.UserNotFoundError:
raise ValueError('Passwordless ssh does not work.') from None


def _create_remote_workdirs(printer, hosts, path, timeout_seconds):
"Create workdirs on remote hosts"
ok = True
Expand Down Expand Up @@ -1778,6 +1785,7 @@ def prepare(self, has_remote_actions):
json.dump(self.data, open(self.statefile, 'w'))
_copy_utils(self.workdir)
if has_remote_actions:
_check_parallax_remote_available(self.printer, self.hosts)
_create_remote_workdirs(self.printer, self.hosts, self.workdir, self.timeout_seconds)
_copy_to_remote_dirs(self.printer, self.hosts, self.workdir, self.timeout_seconds)
# make sure all path references are relative to the script directory
Expand Down Expand Up @@ -2105,7 +2113,10 @@ def run(script, params, printer):
finally:
if not dry_run:
if not config.core.debug:
_run_cleanup(printer, has_remote_actions, local_node, hosts, workdir, int(params['timeout']))
try:
_run_cleanup(printer, has_remote_actions, local_node, hosts, workdir, int(params['timeout']))
except utils.UserOfHost.UserNotFoundError:
pass
elif has_remote_actions:
_print_debug(printer, local_node, hosts, workdir, int(params['timeout']))
else:
Expand Down
2 changes: 1 addition & 1 deletion crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def user_pair_for_ssh(self, host: str) -> typing.Tuple[str, str]:
else:
ret = self._guess_user_for_ssh(host)
if ret is None:
raise self.UserNotFoundError
raise self.UserNotFoundError from None
else:
self._user_pair_cache[host] = ret
return ret
Expand Down

0 comments on commit ae323cd

Please sign in to comment.