From 7db0e669c638bad118dd4611a92cfbd024951738 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 18 May 2023 09:54:23 -0400 Subject: [PATCH] qa/tasks/vstart_runner: update teuthology helper tool paths With [1], these tools are now installed in the teuthology virtualenv. Update the path in the command arguments so these tools can be run via sudo. [1] https://github.com/ceph/teuthology/pull/1846 Signed-off-by: Patrick Donnelly --- qa/tasks/vstart_runner.py | 42 ++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 6549dcaf11bee..ac400726db1ff 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -293,6 +293,15 @@ class LocalRemoteProcess(object): log.debug(f"kill: already terminated ({self.usr_args})") +def find_executable(exe): + for path in os.getenv('PATH').split(':'): + try: + path = os.path.join(path, exe) + os.lstat(path) + return path + except OSError: + pass + return None class LocalRemote(RemoteShell): """ @@ -302,6 +311,21 @@ class LocalRemote(RemoteShell): Run this inside your src/ dir! """ + rewrite_helper_tools = [ + { + 'name': 'adjust-ulimits', + 'path': None + }, + { + 'name': 'daemon-helper', + 'path': None + }, + { + 'name': 'stdin-killer', + 'path': None + }, + ] + def __init__(self): super().__init__() self.name = "local" @@ -328,6 +352,17 @@ class LocalRemote(RemoteShell): except shutil.SameFileError: pass + def _expand_teuthology_tools(self, args): + assert isinstance(args, list) + for tool in self.rewrite_helper_tools: + name, path = tool['name'], tool['path'] + if path is None: + tool['path'] = find_executable(name) + path = tool['path'] + log.info(f"{name} path is {path}") + for i, arg in enumerate(args): + if arg == name: + args[i] = path def _omit_cmd_args(self, args, omit_sudo): """ @@ -335,8 +370,7 @@ class LocalRemote(RemoteShell): using vstart_runner.py. And sudo's omission depends on the value of the variable omit_sudo. """ - helper_tools = ('adjust-ulimits', 'ceph-coverage', - 'None/archive/coverage') + helper_tools = ('ceph-coverage', 'None/archive/coverage') for i in helper_tools: if i in args: helper_tools_found = True @@ -352,9 +386,6 @@ class LocalRemote(RemoteShell): if helper_tools_found: args = args.replace('None/archive/coverage', '') prefix += """ -adjust-ulimits() { - "$@" -} ceph-coverage() { "$@" } @@ -392,6 +423,7 @@ sudo() { def _perform_checks_and_adjustments(self, args, omit_sudo): if isinstance(args, list): + self._expand_teuthology_tools(args) # hack only for list args = quote(args) assert isinstance(args, str) -- 2.39.5