]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
task/install: skip package removal by default 1553/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 26 Aug 2020 14:29:27 +0000 (07:29 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 27 Aug 2020 21:09:38 +0000 (14:09 -0700)
Every teuthology job cleans up its package install after completion.
This was necessary cleanup when we didn't reimage boxes before the use
of FOG as we wanted a "clean" slate for the next job to acquire the
machine. Now this is just unnecessary work which takes up valuable
machine time. For one job I looked at, this takes about 2 minutes.

We should still test that there are no unexpected issues with removing
the packages but this can be delegated to a small subset of smoke tests.
That will be posted in another PR to ceph.git.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
teuthology/orchestra/remote.py
teuthology/task/install/__init__.py

index 680b2c02d2f7dbac614f7a662dc0bc9d316840f7..171c558a2ec6a0b1dbe0091b6ac06f86b2e687cd 100644 (file)
@@ -8,6 +8,7 @@ from teuthology.orchestra import run
 from teuthology.orchestra import connection
 from teuthology.orchestra import console
 from teuthology.orchestra.opsys import OS
+import teuthology.provision
 from teuthology import misc
 from teuthology.exceptions import CommandFailedError
 from teuthology.misc import host_shortname
@@ -33,6 +34,7 @@ class Remote(object):
 
     # for unit tests to hook into
     _runner = staticmethod(run.run)
+    _reimage_types = None
 
     def __init__(self, name, ssh=None, shortname=None, console=None,
                  host_key=None, keep_alive=True):
@@ -53,6 +55,9 @@ class Remote(object):
         self._console = console
         self.ssh = ssh
 
+        if self._reimage_types is None:
+            Remote._reimage_types = teuthology.provision.get_reimage_types()
+
     def connect(self, timeout=None, create_key=None, context='connect'):
         args = dict(user_at_host=self.name, host_key=self._host_key,
                     keep_alive=self.keep_alive, _create_key=create_key)
@@ -150,6 +155,10 @@ class Remote(object):
             self._machine_type = remote_info.get("machine_type", None)
         return self._machine_type
 
+    @property
+    def is_reimageable(self):
+        return self.machine_type in self._reimage_types
+
     @property
     def shortname(self):
         if self._shortname is None:
index 83ffa368f2bb32c60ec403812f11ac820d1248f2..41b62d5665ea861f69637d280bce0650f332d322 100644 (file)
@@ -99,11 +99,13 @@ def remove_packages(ctx, config, pkgs):
         "deb": deb._remove,
         "rpm": rpm._remove,
     }
+    cleanup = config.get('cleanup', False)
     with parallel() as p:
         for remote in ctx.cluster.remotes.keys():
-            system_type = teuthology.get_system_type(remote)
-            p.spawn(remove_pkgs[
-                    system_type], ctx, config, remote, pkgs[system_type])
+            if not remote.is_reimageable or cleanup:
+                system_type = teuthology.get_system_type(remote)
+                p.spawn(remove_pkgs[
+                        system_type], ctx, config, remote, pkgs[system_type])
 
 
 def remove_sources(ctx, config):
@@ -117,13 +119,15 @@ def remove_sources(ctx, config):
         'deb': deb._remove_sources_list,
         'rpm': rpm._remove_sources_list,
     }
+    cleanup = config.get('cleanup', False)
+    project = config.get('project', 'ceph')
     with parallel() as p:
-        project = config.get('project', 'ceph')
-        log.info("Removing {proj} sources lists".format(
-            proj=project))
         for remote in ctx.cluster.remotes.keys():
-            remove_fn = remove_sources_pkgs[remote.os.package_type]
-            p.spawn(remove_fn, ctx, config, remote)
+            if not remote.is_reimageable or cleanup:
+                log.info("Removing {p} sources lists on {r}"
+                         .format(p=project,r=remote))
+                remove_fn = remove_sources_pkgs[remote.os.package_type]
+                p.spawn(remove_fn, ctx, config, remote)
 
 
 def get_package_list(ctx, config):
@@ -588,6 +592,7 @@ def task(ctx, config):
     else:
         nested_config = dict(
                 branch=config.get('branch'),
+                cleanup=config.get('cleanup'),
                 debuginfo=config.get('debuginfo'),
                 downgrade_packages=config.get('downgrade_packages', []),
                 exclude_packages=config.get('exclude_packages', []),