From 3681e3a1a80de645638f16d6d485ecbe5b93c178 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 2 Mar 2021 18:38:36 -0800 Subject: [PATCH] qa: move get_valgrind_args to qa This method is unused in the teuthology repo. The helper method better belongs here where it is more easily modified. Signed-off-by: Patrick Donnelly --- qa/tasks/ceph.py | 6 ++-- qa/tasks/ceph_fuse.py | 10 +++--- qa/tasks/ceph_manager.py | 57 +++++++++++++++++++++++++++++++++++ qa/tasks/cephfs/fuse_mount.py | 6 ++-- qa/tasks/cephfs_mirror.py | 3 +- qa/tasks/rbd_fsx.py | 3 +- qa/tasks/rbd_mirror.py | 3 +- qa/tasks/rgw.py | 3 +- 8 files changed, 75 insertions(+), 16 deletions(-) diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index afd665f76ec..4d0432f95cd 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -21,7 +21,7 @@ import socket import yaml from paramiko import SSHException -from tasks.ceph_manager import CephManager, write_conf +from tasks.ceph_manager import CephManager, write_conf, get_valgrind_args from tarfile import ReadError from tasks.cephfs.filesystem import Filesystem from teuthology import misc as teuthology @@ -1385,9 +1385,7 @@ def run_daemon(ctx, config, type_): valgrind_args = config['valgrind'][type_] if role in config['valgrind']: valgrind_args = config['valgrind'][role] - run_cmd = teuthology.get_valgrind_args(testdir, role, - run_cmd, - valgrind_args) + run_cmd = get_valgrind_args(testdir, role, run_cmd, valgrind_args) run_cmd.extend(run_cmd_tail) log_path = f'/var/log/ceph/{cluster_name}-{type_}.{id_}.log' diff --git a/qa/tasks/ceph_fuse.py b/qa/tasks/ceph_fuse.py index 67432ead41d..d01c313110b 100644 --- a/qa/tasks/ceph_fuse.py +++ b/qa/tasks/ceph_fuse.py @@ -5,7 +5,7 @@ Ceph FUSE client task import contextlib import logging -from teuthology import misc as teuthology +from teuthology import misc from tasks.cephfs.fuse_mount import FuseMount log = logging.getLogger(__name__) @@ -78,7 +78,7 @@ def task(ctx, config): log.info('Running ceph_fuse task...') if config is None: - ids = teuthology.all_roles_of_type(ctx.cluster, 'client') + ids = misc.all_roles_of_type(ctx.cluster, 'client') client_roles = [f'client.{id_}' for id_ in ids] config = dict([r, dict()] for r in client_roles) elif isinstance(config, list): @@ -90,8 +90,8 @@ def task(ctx, config): raise ValueError(f"Invalid config object: {config} ({config.__class__})") log.info(f"config is {config}") - clients = list(teuthology.get_clients(ctx=ctx, roles=client_roles)) - testdir = teuthology.get_testdir(ctx) + clients = list(misc.get_clients(ctx=ctx, roles=client_roles)) + testdir = misc.get_testdir(ctx) all_mounts = getattr(ctx, 'mounts', {}) mounted_by_me = {} skipped = {} @@ -113,7 +113,7 @@ def task(ctx, config): client_config[k] = v # mount specific overrides client_config_overrides = overrides.get(entity) - teuthology.deep_merge(client_config, client_config_overrides) + misc.deep_merge(client_config, client_config_overrides) log.info(f"{entity} config is {client_config}") remotes.add(remote) diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index f28565ef1cb..ce6fec15517 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -68,6 +68,63 @@ def write_conf(ctx, conf_path=DEFAULT_CONF_PATH, cluster='ceph'): teuthology.feed_many_stdins_and_close(conf_fp, writes) run.wait(writes) +def get_valgrind_args(testdir, name, preamble, v, exit_on_first_error=True): + """ + Build a command line for running valgrind. + + testdir - test results directory + name - name of daemon (for naming hte log file) + preamble - stuff we should run before valgrind + v - valgrind arguments + """ + if v is None: + return preamble + if not isinstance(v, list): + v = [v] + + # https://tracker.ceph.com/issues/44362 + preamble.extend([ + 'env', 'OPENSSL_ia32cap=~0x1000000000000000', + ]) + + val_path = '/var/log/ceph/valgrind' + if '--tool=memcheck' in v or '--tool=helgrind' in v: + extra_args = [ + 'valgrind', + '--trace-children=no', + '--child-silent-after-fork=yes', + '--soname-synonyms=somalloc=*tcmalloc*', + '--num-callers=50', + '--suppressions={tdir}/valgrind.supp'.format(tdir=testdir), + '--xml=yes', + '--xml-file={vdir}/{n}.log'.format(vdir=val_path, n=name), + '--time-stamp=yes', + '--vgdb=yes', + ] + else: + extra_args = [ + 'valgrind', + '--trace-children=no', + '--child-silent-after-fork=yes', + '--soname-synonyms=somalloc=*tcmalloc*', + '--suppressions={tdir}/valgrind.supp'.format(tdir=testdir), + '--log-file={vdir}/{n}.log'.format(vdir=val_path, n=name), + '--time-stamp=yes', + '--vgdb=yes', + ] + if exit_on_first_error: + extra_args.extend([ + # at least Valgrind 3.14 is required + '--exit-on-first-error=yes', + '--error-exitcode=42', + ]) + args = [ + 'cd', testdir, + run.Raw('&&'), + ] + preamble + extra_args + v + log.debug('running %s under valgrind with args %s', name, args) + return args + def mount_osd_data(ctx, remote, cluster, osd): """ diff --git a/qa/tasks/cephfs/fuse_mount.py b/qa/tasks/cephfs/fuse_mount.py index 9885c201566..e8279d4b47c 100644 --- a/qa/tasks/cephfs/fuse_mount.py +++ b/qa/tasks/cephfs/fuse_mount.py @@ -5,11 +5,11 @@ import logging from io import StringIO from textwrap import dedent -from teuthology import misc from teuthology.contextutil import MaxWhileTries from teuthology.contextutil import safe_while from teuthology.orchestra import run from teuthology.orchestra.run import CommandFailedError +from tasks.ceph_manager import get_valgrind_args from tasks.cephfs.mount import CephFSMount log = logging.getLogger(__name__) @@ -95,13 +95,13 @@ class FuseMount(CephFSMount): cwd = self.test_dir if self.client_config.get('valgrind') is not None: - run_cmd = misc.get_valgrind_args( + run_cmd = get_valgrind_args( self.test_dir, 'client.{id}'.format(id=self.client_id), run_cmd, self.client_config.get('valgrind'), ) - cwd = None # misc.get_valgrind_args chdir for us + cwd = None # get_valgrind_args chdir for us netns_prefix = ['sudo', 'nsenter', '--net=/var/run/netns/{0}'.format(self.netns_name)] diff --git a/qa/tasks/cephfs_mirror.py b/qa/tasks/cephfs_mirror.py index aa67fca135c..42c01aaea03 100644 --- a/qa/tasks/cephfs_mirror.py +++ b/qa/tasks/cephfs_mirror.py @@ -8,6 +8,7 @@ from teuthology.orchestra import run from teuthology import misc from teuthology.exceptions import ConfigError from teuthology.task import Task +from tasks.ceph_manager import get_valgrind_args from tasks.util import get_remote_for_role log = logging.getLogger(__name__) @@ -42,7 +43,7 @@ class CephFSMirror(Task): ] if 'valgrind' in self.config: - args = misc.get_valgrind_args( + args = get_valgrind_args( testdir, 'cephfs-mirror-{id}'.format(id=self.client), args, self.config.get('valgrind')) diff --git a/qa/tasks/rbd_fsx.py b/qa/tasks/rbd_fsx.py index 396d8fed2a2..efea7208e5e 100644 --- a/qa/tasks/rbd_fsx.py +++ b/qa/tasks/rbd_fsx.py @@ -7,6 +7,7 @@ import logging from teuthology.exceptions import ConfigError from teuthology.parallel import parallel from teuthology import misc as teuthology +from tasks.ceph_manager import get_valgrind_args log = logging.getLogger(__name__) @@ -62,7 +63,7 @@ def _run_one_client(ctx, config, role): teuthology.deep_merge(config, overrides.get('rbd_fsx', {})) if config.get('valgrind'): - args = teuthology.get_valgrind_args( + args = get_valgrind_args( testdir, 'fsx_{id}'.format(id=role), args, diff --git a/qa/tasks/rbd_mirror.py b/qa/tasks/rbd_mirror.py index 5d6d1b2b6eb..5da252560dc 100644 --- a/qa/tasks/rbd_mirror.py +++ b/qa/tasks/rbd_mirror.py @@ -8,6 +8,7 @@ from teuthology.orchestra import run from teuthology import misc from teuthology.exceptions import ConfigError from teuthology.task import Task +from tasks.ceph_manager import get_valgrind_args from tasks.util import get_remote_for_role log = logging.getLogger(__name__) @@ -85,7 +86,7 @@ class RBDMirror(Task): ] if 'valgrind' in self.config: - args = misc.get_valgrind_args( + args = get_valgrind_args( testdir, 'rbd-mirror-{id}'.format(id=self.client), args, diff --git a/qa/tasks/rgw.py b/qa/tasks/rgw.py index 22016566181..c5ffc9a6eb3 100644 --- a/qa/tasks/rgw.py +++ b/qa/tasks/rgw.py @@ -9,6 +9,7 @@ from teuthology.orchestra import run from teuthology import misc as teuthology from teuthology import contextutil from teuthology.exceptions import ConfigError +from tasks.ceph_manager import get_valgrind_args from tasks.util import get_remote_for_role from tasks.util.rgw import rgwadmin, wait_for_radosgw from tasks.util.rados import (create_ec_pool, @@ -153,7 +154,7 @@ def start_rgw(ctx, config, clients): ]) if client_config.get('valgrind'): - cmd_prefix = teuthology.get_valgrind_args( + cmd_prefix = get_valgrind_args( testdir, client_with_cluster, cmd_prefix, -- 2.39.5