]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
task/ceph: Invoke newfs for CephFS as needed
authorJohn Spray <john.spray@inktank.com>
Tue, 27 May 2014 13:12:07 +0000 (14:12 +0100)
committerJohn Spray <jspray@redhat.com>
Mon, 30 Jun 2014 09:40:18 +0000 (10:40 +0100)
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 <john.spray@inktank.com>
teuthology/task/ceph.py

index bc14cb9b6e5b5cbee0b1d5c6e23b4951dd5521de..b1ab5d49b28939b190dd40c0165aff94f49d8bec 100644 (file)
@@ -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: