From: Patrick Donnelly Date: Wed, 26 Aug 2020 14:29:27 +0000 (-0700) Subject: task/install: skip package removal by default X-Git-Tag: 1.1.0~51^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ae764cb599af24594ca029f6336c0a34a6156f8;p=teuthology.git task/install: skip package removal by default 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 --- diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 680b2c02d..171c558a2 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -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: diff --git a/teuthology/task/install/__init__.py b/teuthology/task/install/__init__.py index 83ffa368f..41b62d566 100644 --- a/teuthology/task/install/__init__.py +++ b/teuthology/task/install/__init__.py @@ -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', []),