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
This commit is contained in:
Edward Hope-Morley 2018-09-27 12:10:03 +01:00
parent ac53d3994d
commit 9444b4402c
3 changed files with 33 additions and 24 deletions

View File

@ -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))

View File

@ -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))

View File

@ -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)
]
}