From 182cb630346344a6cb3773012d460fc8dfd14285 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 30 Mar 2015 21:11:35 -0700 Subject: [PATCH] ceph: fix mkfs -f bug Pass -f by default to btrfs instead of first trying without and *then* trying with. Among other things, this avoids a confusing failure where we try mkfs.ext4 device (no -f), fail for some reason, and then try again with -f and get a usage error (-f does not mean force for mke2fs). Signed-off-by: Sage Weil --- tasks/ceph.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tasks/ceph.py b/tasks/ceph.py index 6de47029169..fbe955dfc7d 100644 --- a/tasks/ceph.py +++ b/tasks/ceph.py @@ -529,7 +529,8 @@ def cluster(ctx, config): if mount_options is None: mount_options = ['noatime','user_subvol_rm_allowed'] if mkfs_options is None: - mkfs_options = ['-m', 'single', + mkfs_options = ['-f', + '-m', 'single', '-l', '32768', '-n', '32768'] if fs == 'xfs': @@ -557,15 +558,7 @@ def cluster(ctx, config): stdout=StringIO(), ) - try: - remote.run(args= ['yes', run.Raw('|')] + ['sudo'] + mkfs + [dev]) - except run.CommandFailedError: - # Newer btfs-tools doesn't prompt for overwrite, use -f - if '-f' not in mount_options: - mkfs_options.append('-f') - mkfs = ['mkfs.%s' % fs] + mkfs_options - log.info('%s on %s on %s' % (mkfs, dev, remote)) - remote.run(args= ['yes', run.Raw('|')] + ['sudo'] + mkfs + [dev]) + remote.run(args= ['yes', run.Raw('|')] + ['sudo'] + mkfs + [dev]) log.info('mount %s on %s -o %s' % (dev, remote, ','.join(mount_options)))