Skip to content

Commit

Permalink
orchestra/run: better handle weird args
Browse files Browse the repository at this point in the history
If one of the command args in remote.run is None then there is exception
occurs while trying to qoute argument list:

   TypeError: expected string or bytes-like object

This fix addresses the issue and gives user better idea what is
happening, and how to fix the error.

Fixes: https://tracker.ceph.com/issues/64452

Signed-off-by: Kyr Shatskyy <[email protected]>
  • Loading branch information
Kyr Shatskyy committed Jan 30, 2025
1 parent f6c758f commit 30fa80c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions teuthology/orchestra/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,21 @@ def __eq__(self, value):

def quote(args):
"""
Internal quote wrapper.
Internal quote wrapper. None arguments are not allowed.
:param args: list of str or Raw objects
:raises: :class:`RuntimeError`: if one of the args is None
"""
def _quote(args):
"""
Handle quoted string, testing for raw charaters.
"""
for a in args:
for i, a in enumerate(args):
if isinstance(a, Raw):
yield a.value
elif a is None:
raise RuntimeError(f"Argument at position {i} is None {args}")
else:
yield shlex.quote(a)
if isinstance(args, list):
Expand Down

0 comments on commit 30fa80c

Please sign in to comment.