From 9444b4402cfd3c38d737b2bcdda4fd883319d21a Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Thu, 27 Sep 2018 12:10:03 +0100 Subject: [PATCH] Enable discard By default nova/libvirt will not enable trim for attached volumes so to allow users to use this feature we now enable it by default. Also removed < Icehouse unit test. Change-Id: I58ffaa43e2836068aeed7795df670d279d5e28f8 Closes-Bug: #1781382 --- hooks/cinder_contexts.py | 3 ++ tests/basic_deployment.py | 4 +++ unit_tests/test_cinder_contexts.py | 50 ++++++++++++++++-------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/hooks/cinder_contexts.py b/hooks/cinder_contexts.py index 31130b8..3ebb162 100644 --- a/hooks/cinder_contexts.py +++ b/hooks/cinder_contexts.py @@ -58,6 +58,9 @@ class CephSubordinateContext(OSContextGenerator): ('rbd_secret_uuid', leader_get('secret-uuid')), ('rbd_ceph_conf', ceph_config_file())]} + if CompareOpenStackReleases(os_codename) >= "mitaka": + section[service].append(('report_discard_supported', True)) + if CompareOpenStackReleases(os_codename) >= "queens": section[service].append(('rbd_exclusive_cinder_pool', True)) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index f733be2..7378606 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -358,6 +358,10 @@ class CinderCephBasicDeployment(OpenStackAmuletDeployment): } } + if self._get_openstack_release() >= self.trusty_mitaka: + section = sub_dict['cinder']["/etc/cinder/cinder.conf"]["sections"] + section["cinder-ceph"].append(('report_discard_supported', True)) + if self._get_openstack_release() >= self.xenial_queens: section = sub_dict['cinder']["/etc/cinder/cinder.conf"]["sections"] section["cinder-ceph"].append(('rbd_exclusive_cinder_pool', True)) diff --git a/unit_tests/test_cinder_contexts.py b/unit_tests/test_cinder_contexts.py index bf7c97b..100fe18 100644 --- a/unit_tests/test_cinder_contexts.py +++ b/unit_tests/test_cinder_contexts.py @@ -37,30 +37,6 @@ class TestCinderContext(CharmTestCase): self.is_relation_made.return_value = False self.assertEqual(contexts.CephSubordinateContext()(), {}) - def test_ceph_related(self): - self.is_relation_made.return_value = True - self.get_os_codename_package.return_value = "havana" - service = 'mycinder' - self.service_name.return_value = service - self.assertEqual( - contexts.CephSubordinateContext()(), - {"cinder": { - "/etc/cinder/cinder.conf": { - "sections": { - service: [ - ('volume_backend_name', service), - ('volume_driver', - 'cinder.volume.driver.RBDDriver'), - ('rbd_pool', service), - ('rbd_user', service), - ('rbd_secret_uuid', 'libvirt-uuid'), - ('rbd_ceph_conf', - '/var/lib/charm/mycinder/ceph.conf') - ] - } - } - }}) - def test_ceph_related_icehouse(self): self.is_relation_made.return_value = True self.get_os_codename_package.return_value = "icehouse" @@ -85,6 +61,31 @@ class TestCinderContext(CharmTestCase): } }}) + def test_ceph_related_mitaka(self): + self.is_relation_made.return_value = True + self.get_os_codename_package.return_value = "mitaka" + service = 'mycinder' + self.service_name.return_value = service + self.assertEqual( + contexts.CephSubordinateContext()(), + {"cinder": { + "/etc/cinder/cinder.conf": { + "sections": { + service: [ + ('volume_backend_name', service), + ('volume_driver', + 'cinder.volume.drivers.rbd.RBDDriver'), + ('rbd_pool', service), + ('rbd_user', service), + ('rbd_secret_uuid', 'libvirt-uuid'), + ('rbd_ceph_conf', + '/var/lib/charm/mycinder/ceph.conf'), + ('report_discard_supported', True) + ] + } + } + }}) + def test_ceph_related_queens(self): self.is_relation_made.return_value = True self.get_os_codename_package.return_value = "queens" @@ -104,6 +105,7 @@ class TestCinderContext(CharmTestCase): ('rbd_secret_uuid', 'libvirt-uuid'), ('rbd_ceph_conf', '/var/lib/charm/mycinder/ceph.conf'), + ('report_discard_supported', True), ('rbd_exclusive_cinder_pool', True) ] }