Ensure that directory OSDs stay filestore by default

Partial-Bug: #1713099
Change-Id: I32fc8fe0c67f89d93de0e6647066eadda22911a3
This commit is contained in:
Chris MacNaughton 2017-08-28 13:45:08 +02:00
parent 123ace6c19
commit e79c23d882
2 changed files with 44 additions and 3 deletions

View File

@ -1366,7 +1366,7 @@ def osdize(dev, osd_format, osd_journal, reformat_osd=False,
reformat_osd, ignore_errors, encrypt,
bluestore)
else:
osdize_dir(dev, encrypt)
osdize_dir(dev, encrypt, bluestore)
def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
@ -1395,7 +1395,7 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
if encrypt:
cmd.append('--dmcrypt')
if cmp_pkgrevno('ceph', '0.48.3') >= 0:
if osd_format:
if osd_format and not bluestore:
cmd.append('--fs-type')
cmd.append(osd_format)
@ -1431,7 +1431,7 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
raise
def osdize_dir(path, encrypt=False):
def osdize_dir(path, encrypt=False, bluestore=False):
"""Ask ceph-disk to prepare a directory to become an osd.
:param path: str. The directory to osdize
@ -1459,6 +1459,12 @@ def osdize_dir(path, encrypt=False):
if cmp_pkgrevno('ceph', '0.60') >= 0:
if encrypt:
cmd.append('--dmcrypt')
# NOTE(icey): enable experimental bluestore support
if cmp_pkgrevno('ceph', '10.2.0') >= 0 and bluestore:
cmd.append('--bluestore')
elif cmp_pkgrevno('ceph', '12.1.0') >= 0 and not bluestore:
cmd.append('--filestore')
log("osdize dir cmd: {}".format(cmd))
subprocess.check_call(cmd)

View File

@ -46,6 +46,41 @@ class CephTestCase(unittest.TestCase):
def setUp(self):
super(CephTestCase, self).setUp()
@patch.object(utils.subprocess, 'check_call')
@patch.object(utils.os.path, 'exists')
@patch.object(utils, 'is_device_mounted')
@patch.object(utils, 'cmp_pkgrevno')
@patch.object(utils, 'is_block_device')
def test_osdize_dev(self, _is_blk, _cmp, _mounted, _exists, _call):
"""Test that the dev osd is initialized correctly"""
_is_blk.return_value = True
_mounted.return_value = False
_exists.return_value = True
_cmp.return_value = True
utils.osdize('/dev/sdb', osd_format='xfs', osd_journal=None,
reformat_osd=True, bluestore=False)
_call.assert_called_with(['ceph-disk', 'prepare', '--fs-type', 'xfs',
'--zap-disk', '--filestore', '/dev/sdb'])
@patch.object(utils.subprocess, 'check_call')
@patch.object(utils.os.path, 'exists')
@patch.object(utils, 'is_device_mounted')
@patch.object(utils, 'cmp_pkgrevno')
@patch.object(utils, 'mkdir')
@patch.object(utils, 'chownr')
@patch.object(utils, 'ceph_user')
def test_osdize_dir(self, _ceph_user, _chown, _mkdir,
_cmp, _mounted, _exists, _call):
"""Test that the dev osd is initialized correctly"""
_ceph_user.return_value = "ceph"
_mounted.return_value = False
_exists.return_value = False
_cmp.return_value = True
utils.osdize('/srv/osd', osd_format='xfs', osd_journal=None,
bluestore=False)
_call.assert_called_with(['sudo', '-u', 'ceph', 'ceph-disk', 'prepare',
'--data-dir', '/srv/osd', '--filestore'])
@patch.object(utils.subprocess, 'check_output')
def test_get_osd_weight(self, output):
"""It gives an OSD's weight"""