From 9ff4d4a4e76ebe4ebf5cbe665e9b6bfc227e8fd1 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 12 Dec 2013 13:33:19 -0800 Subject: [PATCH] Fix FSID not being set in ceph.conf Symptom was that 'ceph --admin-daemon... config get fsid' returned zeros, while correct fsid was present in cluster maps. Fix it by populating FSID in ceph.conf, after extracting it from monmap. --- teuthology/misc.py | 10 ++++++++- teuthology/task/ceph.py | 49 ++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 6895c2547727a..85e386d45a733 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -13,6 +13,7 @@ import urllib2 import urlparse import yaml import json +import re from teuthology import safepath from .orchestra import run @@ -251,6 +252,8 @@ def create_simple_monmap(ctx, remote, conf): Assumes ceph_conf is up to date. Assumes mon sections are named "mon.*", with the dot. + + :return the FSID (as a string) of the newly created monmap """ def gen_addresses(): for section, data in conf.iteritems(): @@ -280,9 +283,14 @@ def create_simple_monmap(ctx, remote, conf): '--print', '{tdir}/monmap'.format(tdir=testdir), ]) - remote.run( + + r = remote.run( args=args, + stdout=StringIO() ) + monmap_output = r.stdout.getvalue() + fsid = re.search("generated fsid (.+)$", monmap_output, re.MULTILINE).group(1) + return fsid def write_file(remote, path, data): remote.run( diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index e7e335b7c2cc3..4bd2b59e835fe 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -523,30 +523,8 @@ def cluster(ctx, config): ctx.ceph = argparse.Namespace() ctx.ceph.conf = conf - conf_path = config.get('conf_path', '/etc/ceph/ceph.conf') keyring_path = config.get('keyring_path', '/etc/ceph/ceph.keyring') - log.info('Writing configs...') - conf_fp = StringIO() - conf.write(conf_fp) - conf_fp.seek(0) - writes = ctx.cluster.run( - args=[ - 'sudo', 'mkdir', '-p', '/etc/ceph', run.Raw('&&'), - 'sudo', 'chmod', '0755', '/etc/ceph', run.Raw('&&'), - 'sudo', 'python', - '-c', - 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', - conf_path, - run.Raw('&&'), - 'sudo', 'chmod', '0644', conf_path, - ], - stdin=run.PIPE, - wait=False, - ) - teuthology.feed_many_stdins_and_close(conf_fp, writes) - run.wait(writes) - coverage_dir = '{tdir}/archive/coverage'.format(tdir=testdir) firstmon = teuthology.get_first_mon(ctx, config) @@ -584,11 +562,36 @@ def cluster(ctx, config): ], ) (mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys() - teuthology.create_simple_monmap( + fsid = teuthology.create_simple_monmap( ctx, remote=mon0_remote, conf=conf, ) + if not 'global' in conf: + conf['global'] = {} + conf['global']['fsid'] = fsid + + log.info('Writing ceph.conf for FSID %s...' % fsid) + conf_path = config.get('conf_path', '/etc/ceph/ceph.conf') + conf_fp = StringIO() + conf.write(conf_fp) + conf_fp.seek(0) + writes = ctx.cluster.run( + args=[ + 'sudo', 'mkdir', '-p', '/etc/ceph', run.Raw('&&'), + 'sudo', 'chmod', '0755', '/etc/ceph', run.Raw('&&'), + 'sudo', 'python', + '-c', + 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', + conf_path, + run.Raw('&&'), + 'sudo', 'chmod', '0644', conf_path, + ], + stdin=run.PIPE, + wait=False, + ) + teuthology.feed_many_stdins_and_close(conf_fp, writes) + run.wait(writes) log.info('Creating admin key on %s...' % firstmon) ctx.cluster.only(firstmon).run( -- 2.39.5