From 5b0924494afa7e9eeb06217ef46a81190ba1ae9c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 26 Jul 2011 21:46:47 -0700 Subject: [PATCH] tolerate named (not numbered) mons --- teuthology/misc.py | 3 ++- teuthology/task/ceph.py | 32 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 94a3ba2a189de..a3120391e6aec 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -66,15 +66,16 @@ def feed_many_stdins_and_close(fp, processes): def get_mons(roles, ips): mons = {} + mon_id = 0 for idx, roles in enumerate(roles): for role in roles: if not role.startswith('mon.'): continue - mon_id = int(role[len('mon.'):]) addr = '{ip}:{port}'.format( ip=ips[idx], port=6789+mon_id, ) + ++mon_id mons[role] = addr assert mons return mons diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index 2305fe6728e2c..072acc3497bef 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -208,6 +208,18 @@ def binaries(ctx, config): ), ) +# return the "first" mon (alphanumerically, for lack of anything better) +def get_first_mon(ctx, config): + mons = [] + for remote, roles in ctx.cluster.remotes.items(): + for role in roles: + if not role.startswith('mon.'): + continue + mons.append(role) + break + firstmon = sorted(mons)[0] + assert firstmon + return firstmon @contextlib.contextmanager def cluster(ctx, config): @@ -253,8 +265,10 @@ def cluster(ctx, config): coverage_dir = '/tmp/cephtest/archive/coverage' - log.info('Setting up mon.0...') - ctx.cluster.only('mon.0').run( + firstmon = get_first_mon(ctx, config) + + log.info('Setting up %s...' % firstmon) + ctx.cluster.only(firstmon).run( args=[ '/tmp/cephtest/enable-coredump', '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', @@ -264,7 +278,7 @@ def cluster(ctx, config): '/tmp/cephtest/ceph.keyring', ], ) - ctx.cluster.only('mon.0').run( + ctx.cluster.only(firstmon).run( args=[ '/tmp/cephtest/enable-coredump', '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', @@ -275,14 +289,14 @@ def cluster(ctx, config): '/tmp/cephtest/ceph.keyring', ], ) - (mon0_remote,) = ctx.cluster.only('mon.0').remotes.keys() + (mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys() teuthology.create_simple_monmap( remote=mon0_remote, conf=conf, ) - log.info('Creating admin key on mon.0...') - ctx.cluster.only('mon.0').run( + log.info('Creating admin key on %s...' % firstmon) + ctx.cluster.only(firstmon).run( args=[ '/tmp/cephtest/enable-coredump', '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', @@ -601,6 +615,7 @@ def osd(ctx, config): @contextlib.contextmanager def mds(ctx, config): log.info('Starting mds daemons...') + firstmon = get_first_mon(ctx, config) mds_daemons = {} mdss = ctx.cluster.only(teuthology.is_type('mds')) coverage_dir = '/tmp/cephtest/archive/coverage' @@ -631,7 +646,7 @@ def mds(ctx, config): ) mds_daemons[id_] = proc - (mon0_remote,) = ctx.cluster.only('mon.0').remotes.keys() + (mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys() mon0_remote.run(args=[ '/tmp/cephtest/enable-coredump', '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', @@ -652,7 +667,8 @@ def mds(ctx, config): def healthy(ctx, config): log.info('Waiting until ceph is healthy...') - (mon0_remote,) = ctx.cluster.only('mon.0').remotes.keys() + firstmon = get_first_mon(ctx, config) + (mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys() teuthology.wait_until_healthy( remote=mon0_remote, ) -- 2.39.5