From: John Spray Date: Tue, 27 May 2014 13:12:07 +0000 (+0100) Subject: task/ceph: Invoke newfs for CephFS as needed X-Git-Tag: 1.1.0~1361^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8be756a065ed041e64edecac4fbafa7d09f01398;p=teuthology.git task/ceph: Invoke newfs for CephFS as needed New ceph versions will no longer create the CephFS pools and will not enable the filesystem by default. This change adds an explicit step to the cluster initialization to create the filesystem if it doesn't already exist. Signed-off-by: John Spray --- diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index bc14cb9b6..b1ab5d49b 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -436,6 +436,35 @@ def write_conf(ctx, conf_path=DEFAULT_CONF_PATH): run.wait(writes) +@contextlib.contextmanager +def cephfs_setup(ctx, config): + first_mon = teuthology.get_first_mon(ctx, config) + (mon_remote,) = ctx.cluster.only(first_mon).remotes.iterkeys() + mdss = ctx.cluster.only(teuthology.is_type('mds')) + # If there are any MDSs, then create a filesystem for them to use + # Do this last because requires mon cluster to be up and running + if mdss.remotes: + log.info('Setting up CephFS filesystem...') + + proc = mon_remote.run(args=['sudo', 'ceph', '--format=json-pretty', 'osd', 'lspools'], + stdout=StringIO()) + pools = json.loads(proc.stdout.getvalue()) + + # In case we are using an older Ceph which creates FS by default + if 'metadata' in [p['poolname'] for p in pools]: + log.info("Metadata pool already exists, skipping") + else: + mon_remote.run(args=['sudo', 'ceph', 'osd', 'pool', 'create', 'metadata', '256']) + mon_remote.run(args=['sudo', 'ceph', 'osd', 'pool', 'create', 'data', '256']) + + # Use 'newfs' to work with either old or new Ceph, until the 'fs new' + # stuff is all landed. + mon_remote.run(args=['sudo', 'ceph', 'mds', 'newfs', '1', '2']) + # mon_remote.run(args=['sudo', 'ceph', 'fs', 'new', 'default', 'metadata', 'data']) + + yield + + @contextlib.contextmanager def cluster(ctx, config): """ @@ -1457,6 +1486,7 @@ def task(ctx, config): )), lambda: run_daemon(ctx=ctx, config=config, type_='mon'), lambda: run_daemon(ctx=ctx, config=config, type_='osd'), + lambda: cephfs_setup(ctx=ctx, config=config), lambda: run_daemon(ctx=ctx, config=config, type_='mds'), ): try: