From ea7c39222ae084c90b5a8510ce5af35a2f75a6e3 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 6 Apr 2015 19:53:50 +0100 Subject: [PATCH] tasks/ceph: refactor legacy FS configuration check Move up into Filesystem so that this can be used from the ceph_deploy task as well. Signed-off-by: John Spray --- tasks/ceph.py | 21 ++------------------- tasks/cephfs/filesystem.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tasks/ceph.py b/tasks/ceph.py index 6de4702916929..ddd95fd5f0574 100644 --- a/tasks/ceph.py +++ b/tasks/ceph.py @@ -18,7 +18,6 @@ from teuthology import misc as teuthology from teuthology import contextutil from teuthology.orchestra import run import ceph_client as cclient -from teuthology.orchestra.run import CommandFailedError from teuthology.orchestra.daemon import DaemonGroup @@ -202,24 +201,8 @@ def cephfs_setup(ctx, config): if mdss.remotes: log.info('Setting up CephFS filesystem...') - try: - proc = mon_remote.run(args=['sudo', 'ceph', '--format=json-pretty', 'osd', 'lspools'], - stdout=StringIO()) - pools = json.loads(proc.stdout.getvalue()) - metadata_pool_exists = 'metadata' in [p['poolname'] for p in pools] - except CommandFailedError as e: - # For use in upgrade tests, Ceph cuttlefish and earlier don't support - # structured output (--format) from the CLI. - if e.exitstatus == 22: - metadata_pool_exists = True - else: - raise - - # In case we are using an older Ceph which creates FS by default - if metadata_pool_exists: - log.info("Metadata pool already exists, skipping") - else: - ceph_fs = Filesystem(ctx) + ceph_fs = Filesystem(ctx) + if not ceph_fs.legacy_configured(): ceph_fs.create() is_active_mds = lambda role: role.startswith('mds.') and not role.endswith('-s') and role.find('-s-') == -1 diff --git a/tasks/cephfs/filesystem.py b/tasks/cephfs/filesystem.py index b7b4d606265af..74f1c1a75ac90 100644 --- a/tasks/cephfs/filesystem.py +++ b/tasks/cephfs/filesystem.py @@ -70,6 +70,26 @@ class Filesystem(object): self.mon_remote.run(args=['sudo', 'ceph', 'osd', 'pool', 'delete', 'data', 'data', '--yes-i-really-really-mean-it']) + def legacy_configured(self): + """ + Check if a legacy (i.e. pre "fs new") filesystem configuration is present. If this is + the case, the caller should avoid using Filesystem.create + """ + try: + proc = self.mon_remote.run(args=['sudo', 'ceph', '--format=json-pretty', 'osd', 'lspools'], + stdout=StringIO()) + pools = json.loads(proc.stdout.getvalue()) + metadata_pool_exists = 'metadata' in [p['poolname'] for p in pools] + except CommandFailedError as e: + # For use in upgrade tests, Ceph cuttlefish and earlier don't support + # structured output (--format) from the CLI. + if e.exitstatus == 22: + metadata_pool_exists = True + else: + raise + + return metadata_pool_exists + def _df(self): return json.loads(self.mon_manager.raw_cluster_cmd("df", "--format=json-pretty")) -- 2.39.5