From 6f36269d24ab18cea11751bf860901a572741ba7 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 3 Sep 2014 12:23:13 +0100 Subject: [PATCH] tasks: generalize config writing for Filesystem Signed-off-by: John Spray --- tasks/cephfs/filesystem.py | 9 +++++++++ tasks/mds_journal_migration.py | 11 ++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tasks/cephfs/filesystem.py b/tasks/cephfs/filesystem.py index 3cd6206dbc6..df0d2b21a2b 100644 --- a/tasks/cephfs/filesystem.py +++ b/tasks/cephfs/filesystem.py @@ -3,6 +3,7 @@ from StringIO import StringIO import json import logging import time +from tasks.ceph import write_conf from teuthology import misc from teuthology.nuke import clear_firewall @@ -49,6 +50,14 @@ class Filesystem(object): return list(result) + def set_ceph_conf(self, subsys, key, value): + # Set config so that journal will be created in older format + if 'mds' not in self._ctx.ceph.conf: + self._ctx.ceph.conf['mds'] = {} + self._ctx.ceph.conf['mds'][key] = value + write_conf(self._ctx) # XXX because we don't have the ceph task's config object, if they + # used a different config path this won't work. + def are_daemons_healthy(self): """ Return true if all daemons are in one of active, standby, standby-replay diff --git a/tasks/mds_journal_migration.py b/tasks/mds_journal_migration.py index daaedc911db..d10982d5ffc 100644 --- a/tasks/mds_journal_migration.py +++ b/tasks/mds_journal_migration.py @@ -4,7 +4,6 @@ import logging from teuthology import misc from tasks.workunit import task as workunit -from tasks.ceph import write_conf from cephfs.filesystem import Filesystem log = logging.getLogger(__name__) @@ -56,12 +55,7 @@ def task(ctx, config): old_journal_version = JOURNAL_FORMAT_LEGACY new_journal_version = JOURNAL_FORMAT_RESILIENT - # Set config so that journal will be created in older format - if 'mds' not in ctx.ceph.conf: - ctx.ceph.conf['mds'] = {} - ctx.ceph.conf['mds']['mds journal format'] = old_journal_version - write_conf(ctx) # XXX because we don't have the ceph task's config object, if they - # used a different config path this won't work. + fs.set_ceph_conf('mds', 'mds journal format', old_journal_version) # Create a filesystem using the older journal format. for mount in ctx.mounts.values(): @@ -86,8 +80,7 @@ def task(ctx, config): }) # Modify the ceph.conf to ask the MDS to use the new journal format. - ctx.ceph.conf['mds']['mds journal format'] = new_journal_version - write_conf(ctx) + fs.set_ceph_conf('mds', 'mds journal format', new_journal_version) # Restart the MDS. fs.mds_fail_restart()