Merge pull request #47898 from adk3798/no-sudo-true

mgr/cephadm: don't use "sudo" in commands if user is root

Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Redouane Kachach <rkachach@redhat.com>
This commit is contained in:
Adam King 2022-09-13 08:56:18 -04:00 committed by GitHub
commit ecd2170bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,7 +140,7 @@ class SSHManager:
cmd = sudo_prefix + " ".join(quote(x) for x in cmd)
logger.debug(f'Running command: {cmd}')
try:
r = await conn.run('sudo true', check=True, timeout=5)
r = await conn.run(f'{sudo_prefix}true', check=True, timeout=5)
r = await conn.run(cmd, input=stdin)
# handle these Exceptions otherwise you might get a weird error like TypeError: __init__() missing 1 required positional argument: 'reason' (due to the asyncssh error interacting with raise_if_exception)
except (asyncssh.ChannelOpenError, asyncssh.ProcessError, Exception) as e: