teuthology: run the ship_utilities task only once
This will make sure that the utilities won't removed until the last
user is unwound.
@@ -51,18 +51,14 @@ def get_flavor(config):
flavor = 'gcov'
return flavor
-
-@contextlib.contextmanager
-def ship_utilities(ctx, config):
+def _ship_utilities(ctx):
"""
Write a copy of valgrind.supp to each of the remote sites. Set executables
used by Ceph in /usr/local/bin. When finished (upon exit of the teuthology
run), remove these files.
:param ctx: Context
- :param config: Configuration
"""
- assert config is None
testdir = teuthology.get_testdir(ctx)
filenames = []
@@ -109,11 +105,18 @@ def ship_utilities(ctx, config):
dst,
],
)
+ return filenames
- try:
- yield
- finally:
+def _remove_utilities(ctx, filenames):
+ """
+ Remove the shipped utilities.
+
+ :param ctx: Context
+ :param filenames: The utilities install paths
+ """
log.info('Removing shipped files: %s...', ' '.join(filenames))
+ if filenames == []:
+ return
run.wait(
ctx.cluster.run(
args=[
@@ -125,3 +128,26 @@ def ship_utilities(ctx, config):
wait=False,
),
)
+
+@contextlib.contextmanager
+def ship_utilities(ctx, config):
+ """
+ Ship utilities during the first call, and skip it in the following ones.
+ See also `_ship_utilities`.
+
+ :param ctx: Context
+ :param config: Configuration
+ """
+ assert config is None
+
+ do_ship_utilities = ctx.get('do_ship_utilities', True)
+ if do_ship_utilities:
+ ctx['do_ship_utilities'] = False
+ filenames = _ship_utilities(ctx)
+ try:
+ yield
+ finally:
+ _remove_utilities(ctx, filenames)
+ else:
+ log.info('Utilities already shipped, skip it...')
+ yield
