]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
mgr/cephadm: execute commands run over ssh via asyncssh
authorMelissa <li.melissa.kun@gmail.com>
Tue, 20 Jul 2021 21:02:40 +0000 (17:02 -0400)
committerMelissa Li <li.melissa.kun@gmail.com>
Fri, 20 Aug 2021 18:27:45 +0000 (14:27 -0400)
commit4c84e71f4350e9fd7c12944491b99eff02e8dbb2
tree703fffbc9b97d25d7e14f723543288e17c97729a
parentf45ad8107b4ad179746c6c3770042ed89fe0236b
mgr/cephadm: execute commands run over ssh via asyncssh

_execute_command will run commands over ssh using the asyncssh `run` method: https://asyncssh.readthedocs.io/en/latest/api.html#asyncssh.SSHClientConnection.run
_check_execute_command will check the output of _execute_command and raise OrchestratorError if command fails on the remote host.
All commands run over ssh are prepended with sudo in `_execute_command` and shell-escaped with shlex quote.
If the cached ssh connection is closed or broken, the connection object will be removed from the cache, added to the `offline_hosts`, and an OrchestratorError will be raised. On the next call, the connection object will attempt to be recreated.
Exceptions involving asyncssh methods should be handled otherwise errors like TypeError: __init__() missing 1 required positional argument: 'reason' could occur due to the asyncssh error interacting with `raise_if_exception`

Fixes: https://tracker.ceph.com/issues/44676
Signed-off-by: Melissa Li <li.melissa.kun@gmail.com>
src/pybind/mgr/cephadm/ssh.py