Add bluestore support for OSD's

Add highly experimental support for bluestore storage format for
OSD devices; this is disabled by default and should only be enabled
in deployments where loss of data does not present a problem!

Change-Id: I21beff9ce535f1b5c16d7f6f51c35126cc7da43e
Depends-On: I36f7aa9d7b96ec5c9eaa7a3a970593f9ca14cb34
This commit is contained in:
James Page 2017-07-07 09:48:49 +01:00
parent 70eac013d8
commit ca8a5c332c
6 changed files with 76 additions and 9 deletions

View File

@ -42,7 +42,8 @@ def add_device(request, device_path, bucket=None):
ceph.osdize(dev, config('osd-format'),
get_journal_devices(), config('osd-reformat'),
config('ignore-device-errors'),
config('osd-encrypt'))
config('osd-encrypt'),
config('bluestore'))
# Make it fast!
if config('autotune'):
ceph.tune_dev(dev)

View File

@ -64,6 +64,12 @@ options:
btrfs (experimental and not recommended)
Only supported with ceph >= 0.48.3.
bluestore:
type: boolean
default: false
description: |
Use experimental bluestore storage format for OSD devices; only supported
in Ceph Jewel (10.2.0) or later.
osd-reformat:
type: string
default:

View File

@ -257,6 +257,7 @@ def get_ceph_context(upgrading=False):
'dio': str(config('use-direct-io')).lower(),
'short_object_len': use_short_objects(),
'upgrade_in_progress': upgrading,
'bluestore': config('bluestore'),
}
if config('prefer-ipv6'):
@ -376,7 +377,8 @@ def prepare_disks_and_activate():
ceph.osdize(dev, config('osd-format'),
osd_journal, config('osd-reformat'),
config('ignore-device-errors'),
config('osd-encrypt'))
config('osd-encrypt'),
config('bluestore'))
# Make it fast!
if config('autotune'):
ceph.tune_dev(dev)

View File

@ -1299,6 +1299,15 @@ def bootstrap_monitor_cluster(secret):
service_restart('ceph-mon')
else:
service_restart('ceph-mon-all')
if cmp_pkgrevno('ceph', '12.0.0') >= 0:
# NOTE(jamespage): Later ceph releases require explicit
# call to ceph-create-keys to setup the
# admin keys for the cluster; this command
# will wait for quorum in the cluster before
# returning.
cmd = ['ceph-create-keys', '--id', hostname]
subprocess.check_call(cmd)
except:
raise
finally:
@ -1346,16 +1355,17 @@ def find_least_used_journal(journal_devices):
def osdize(dev, osd_format, osd_journal, reformat_osd=False,
ignore_errors=False, encrypt=False):
ignore_errors=False, encrypt=False, bluestore=False):
if dev.startswith('/dev'):
osdize_dev(dev, osd_format, osd_journal,
reformat_osd, ignore_errors, encrypt)
reformat_osd, ignore_errors, encrypt,
bluestore)
else:
osdize_dir(dev, encrypt)
def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
ignore_errors=False, encrypt=False):
ignore_errors=False, encrypt=False, bluestore=False):
if not os.path.exists(dev):
log('Path {} does not exist - bailing'.format(dev))
return
@ -1383,9 +1393,16 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False,
if osd_format:
cmd.append('--fs-type')
cmd.append(osd_format)
if reformat_osd:
cmd.append('--zap-disk')
# NOTE(jamespage): enable experimental bluestore support
if cmp_pkgrevno('ceph', '10.2.0') >= 0 and bluestore:
cmd.append('--bluestore')
cmd.append(dev)
if osd_journal:
least_used = find_least_used_journal(osd_journal)
cmd.append(least_used)

View File

@ -41,6 +41,10 @@ setuser match path = /var/lib/ceph/$type/$cluster-$id
{% endfor %}
{% endif %}
{% if bluestore -%}
enable experimental unrecoverable data corrupting features = bluestore rocksdb
{%- endif %}
[client.osd-upgrade]
keyring = /var/lib/ceph/osd/ceph.client.osd-upgrade.keyring

View File

@ -28,7 +28,8 @@ CHARM_CONFIG = {'config-flags': '',
'use-direct-io': True,
'osd-format': 'ext4',
'prefer-ipv6': False,
'customize-failure-domain': False}
'customize-failure-domain': False,
'bluestore': False}
class CephHooksTestCase(unittest.TestCase):
@ -63,7 +64,41 @@ class CephHooksTestCase(unittest.TestCase):
'public_addr': '10.0.0.1',
'short_object_len': True,
'upgrade_in_progress': False,
'use_syslog': 'true'}
'use_syslog': 'true',
'bluestore': False}
self.assertEqual(ctxt, expected)
@patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234')
@patch.object(ceph_hooks, 'get_auth', lambda *args: False)
@patch.object(ceph_hooks, 'get_public_addr', lambda *args: "10.0.0.1")
@patch.object(ceph_hooks, 'get_cluster_addr', lambda *args: "10.1.0.1")
@patch.object(ceph_hooks, 'cmp_pkgrevno', lambda *args: 1)
@patch.object(ceph_hooks, 'get_mon_hosts', lambda *args: ['10.0.0.1',
'10.0.0.2'])
@patch.object(ceph_hooks, 'get_networks', lambda *args: "")
@patch.object(ceph, 'config')
@patch.object(ceph_hooks, 'config')
def test_get_ceph_context_bluestore(self, mock_config, mock_config2):
config = copy.deepcopy(CHARM_CONFIG)
config['bluestore'] = True
mock_config.side_effect = lambda key: config[key]
mock_config2.side_effect = lambda key: config[key]
ctxt = ceph_hooks.get_ceph_context()
expected = {'auth_supported': False,
'ceph_cluster_network': '',
'ceph_public_network': '',
'cluster_addr': '10.1.0.1',
'dio': 'true',
'fsid': '1234',
'loglevel': 1,
'mon_hosts': '10.0.0.1 10.0.0.2',
'old_auth': False,
'osd_journal_size': 1024,
'public_addr': '10.0.0.1',
'short_object_len': True,
'upgrade_in_progress': False,
'use_syslog': 'true',
'bluestore': True}
self.assertEqual(ctxt, expected)
@patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234')
@ -96,7 +131,8 @@ class CephHooksTestCase(unittest.TestCase):
'public_addr': '10.0.0.1',
'short_object_len': True,
'upgrade_in_progress': False,
'use_syslog': 'true'}
'use_syslog': 'true',
'bluestore': False}
self.assertEqual(ctxt, expected)
@patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234')
@ -131,7 +167,8 @@ class CephHooksTestCase(unittest.TestCase):
'public_addr': '10.0.0.1',
'short_object_len': True,
'upgrade_in_progress': False,
'use_syslog': 'true'}
'use_syslog': 'true',
'bluestore': False}
self.assertEqual(ctxt, expected)
@patch.object(ceph_hooks, 'ceph')