Run daemons for a role type. Handle the startup and termination of a a daemon. On startup -- set coverages, cpu_profile, valgrind values for all remotes, and a max_mds value for one mds. On cleanup -- Stop all existing daemons of this type. :param ctx: Context :param confi
(ctx, config, type_)
| 1397 | |
| 1398 | @contextlib.contextmanager |
| 1399 | def run_daemon(ctx, config, type_): |
| 1400 | """ |
| 1401 | Run daemons for a role type. Handle the startup and termination of a a daemon. |
| 1402 | On startup -- set coverages, cpu_profile, valgrind values for all remotes, |
| 1403 | and a max_mds value for one mds. |
| 1404 | On cleanup -- Stop all existing daemons of this type. |
| 1405 | |
| 1406 | :param ctx: Context |
| 1407 | :param config: Configuration |
| 1408 | :param type_: Role type |
| 1409 | """ |
| 1410 | cluster_name = config['cluster'] |
| 1411 | log.info('Starting %s daemons in cluster %s...', type_, cluster_name) |
| 1412 | testdir = teuthology.get_testdir(ctx) |
| 1413 | daemons = ctx.cluster.only(teuthology.is_type(type_, cluster_name)) |
| 1414 | |
| 1415 | # check whether any daemons if this type are configured |
| 1416 | if daemons is None: |
| 1417 | return |
| 1418 | coverage_dir = '{tdir}/archive/coverage'.format(tdir=testdir) |
| 1419 | |
| 1420 | daemon_signal = 'kill' |
| 1421 | if config.get('coverage') or config.get('valgrind') is not None: |
| 1422 | daemon_signal = 'term' |
| 1423 | |
| 1424 | # create osds in order. (this only matters for pre-luminous, which might |
| 1425 | # be jewel/hammer, which doesn't take an id_ argument to legacy 'osd create'). |
| 1426 | osd_uuids = {} |
| 1427 | for remote, roles_for_host in daemons.remotes.items(): |
| 1428 | is_type_ = teuthology.is_type(type_, cluster_name) |
| 1429 | for role in roles_for_host: |
| 1430 | if not is_type_(role): |
| 1431 | continue |
| 1432 | _, _, id_ = teuthology.split_role(role) |
| 1433 | |
| 1434 | |
| 1435 | if type_ == 'osd': |
| 1436 | datadir='/var/lib/ceph/osd/{cluster}-{id}'.format( |
| 1437 | cluster=cluster_name, id=id_) |
| 1438 | osd_uuid = remote.read_file( |
| 1439 | datadir + '/fsid', sudo=True).decode().strip() |
| 1440 | osd_uuids[id_] = osd_uuid |
| 1441 | for osd_id in range(len(osd_uuids)): |
| 1442 | id_ = str(osd_id) |
| 1443 | osd_uuid = osd_uuids.get(id_) |
| 1444 | try: |
| 1445 | remote.run( |
| 1446 | args=[ |
| 1447 | 'sudo', 'ceph', '--cluster', cluster_name, |
| 1448 | 'osd', 'new', osd_uuid, id_, |
| 1449 | ] |
| 1450 | ) |
| 1451 | except: |
| 1452 | # fallback to pre-luminous (jewel) |
| 1453 | remote.run( |
| 1454 | args=[ |
| 1455 | 'sudo', 'ceph', '--cluster', cluster_name, |
| 1456 | 'osd', 'create', osd_uuid, |
no test coverage detected