diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 46c0103d505e9a8f191f3dbb950f21f5c0403a03..add17ffc497bcaff6ee4f2e88b1d8caf41b3677f 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -251,6 +251,7 @@ def get_ceph_context(upgrading=False): 'short_object_len': use_short_objects(), 'upgrade_in_progress': upgrading, 'bluestore': config('bluestore'), + 'bluestore_experimental': cmp_pkgrevno('ceph', '12.1.0') < 0, } if config('prefer-ipv6'): diff --git a/templates/ceph.conf b/templates/ceph.conf index f7b530c900e76391a0eed5b9d064c204df671e91..fb45e36a327f655226820bc42e862ce43caabafa 100644 --- a/templates/ceph.conf +++ b/templates/ceph.conf @@ -41,7 +41,7 @@ setuser match path = /var/lib/ceph/$type/$cluster-$id {% endfor %} {% endif %} -{% if bluestore -%} +{% if bluestore_experimental and bluestore -%} enable experimental unrecoverable data corrupting features = bluestore rocksdb {%- endif %} @@ -56,9 +56,17 @@ 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 8594afbc52c67ae60b48a845f3e0b6f7b0352df6..c3b95e2d93a4b9032d8349f2c5deee1903580c79 100644 --- a/unit_tests/test_ceph_hooks.py +++ b/unit_tests/test_ceph_hooks.py @@ -65,7 +65,42 @@ class CephHooksTestCase(unittest.TestCase): 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', - 'bluestore': False} + 'bluestore': False, + 'bluestore_experimental': 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 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, + 'upgrade_in_progress': False, + 'use_syslog': 'true', + 'bluestore': False, + 'bluestore_experimental': True} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234') @@ -98,7 +133,43 @@ class CephHooksTestCase(unittest.TestCase): 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', - 'bluestore': True} + 'bluestore': True, + 'bluestore_experimental': 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 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, + 'upgrade_in_progress': False, + 'use_syslog': 'true', + 'bluestore': True, + 'bluestore_experimental': True} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234') @@ -132,7 +203,8 @@ class CephHooksTestCase(unittest.TestCase): 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', - 'bluestore': False} + 'bluestore': False, + 'bluestore_experimental': False} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234') @@ -168,7 +240,8 @@ class CephHooksTestCase(unittest.TestCase): 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', - 'bluestore': False} + 'bluestore': False, + 'bluestore_experimental': False} self.assertEqual(ctxt, expected) @patch.object(ceph_hooks, 'ceph')