diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 1184150..ec9d266 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -201,6 +201,7 @@ def get_ceph_context(): 'dio': str(config('use-direct-io')).lower(), 'short_object_len': use_short_objects(), 'bluestore': config('bluestore'), + 'bluestore_experimental': cmp_pkgrevno('ceph', '12.1.0') < 0, } if config('prefer-ipv6'): diff --git a/lib/ceph/utils.py b/lib/ceph/utils.py index e0fd6be..e0c9f39 100644 --- a/lib/ceph/utils.py +++ b/lib/ceph/utils.py @@ -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) diff --git a/templates/ceph.conf b/templates/ceph.conf index 34d4006..20fd07e 100644 --- a/templates/ceph.conf +++ b/templates/ceph.conf @@ -37,7 +37,7 @@ cluster addr = {{ cluster_addr }} {% endfor %} {% endif %} -{% if bluestore -%} +{% if bluestore_experimental and bluestore -%} enable experimental unrecoverable data corrupting features = bluestore rocksdb {%- endif %} @@ -68,9 +68,16 @@ keyring = /var/lib/ceph/mds/$cluster-$id/keyring [osd] keyring = /var/lib/ceph/osd/$cluster-$id/keyring +{% if bluestore -%} +{% if not bluestore_experimental -%} +osd objectstore = bluestore +{%- endif -%} +{%- else %} osd journal size = {{ osd_journal_size }} filestore xattr use omap = true journal dio = {{ dio }} +{%- endif %} + {%- if short_object_len %} osd max object name len = 256 osd max object namespace len = 64 diff --git a/unit_tests/test_ceph_hooks.py b/unit_tests/test_ceph_hooks.py index 154328f..2ce4a98 100644 --- a/unit_tests/test_ceph_hooks.py +++ b/unit_tests/test_ceph_hooks.py @@ -62,7 +62,39 @@ class CephHooksTestCase(unittest.TestCase): 'public_addr': '10.0.0.1', 'short_object_len': True, 'use_syslog': 'true', - 'bluestore': False} + 'bluestore': False, + 'bluestore_experimental': False} + self.assertEqual(ctxt, expected) + + @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 pkg, ver: -1 if ver == '12.1.0' else 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_filestore_old(self, mock_config, mock_config2): + config = copy.deepcopy(CHARM_CONFIG) + 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, + 'use_syslog': 'true', + 'bluestore': False, + 'bluestore_experimental': True} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'get_public_addr', lambda *args: "10.0.0.1") @@ -92,7 +124,40 @@ class CephHooksTestCase(unittest.TestCase): 'public_addr': '10.0.0.1', 'short_object_len': True, 'use_syslog': 'true', - 'bluestore': True} + 'bluestore': True, + 'bluestore_experimental': False} + self.assertEqual(ctxt, expected) + + @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 pkg, ver: -1 if ver == '12.1.0' else 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_old(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, + 'use_syslog': 'true', + 'bluestore': True, + 'bluestore_experimental': True} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'get_public_addr', lambda *args: "10.0.0.1") @@ -123,7 +188,8 @@ class CephHooksTestCase(unittest.TestCase): 'public_addr': '10.0.0.1', 'short_object_len': True, 'use_syslog': 'true', - 'bluestore': False} + 'bluestore': False, + 'bluestore_experimental': False} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'get_public_addr', lambda *args: "10.0.0.1") @@ -156,7 +222,8 @@ class CephHooksTestCase(unittest.TestCase): 'public_addr': '10.0.0.1', 'short_object_len': True, 'use_syslog': 'true', - 'bluestore': False} + 'bluestore': False, + 'bluestore_experimental': False} self.assertEqual(ctxt, expected) def test_nrpe_dependency_installed(self):