]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/vstart_runner: update teuthology helper tool paths
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 18 May 2023 13:54:23 +0000 (09:54 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 1 Aug 2023 15:16:27 +0000 (11:16 -0400)
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 <pdonnell@redhat.com>
qa/tasks/vstart_runner.py

index 6549dcaf11bee167ba44cab2c963672fb82298d3..ac400726db1ffc7b876d1293d8880dfbd93f063c 100644 (file)
@@ -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)