From 2603a774b112dc6e25f9e7b2071124ea3d3d0012 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Tue, 28 Sep 2021 15:37:15 -0300 Subject: [PATCH] Group cinder-volume services using cluster config Usage of "host" config for grouping cinder-volume services for the purpose of stateless config and/or active-active HA is not recommended. The usage of "cluster" config is recommended for achieving that behavior. This change replaces the usage of "host" with "cluster". Change-Id: I249ce179cfdaf2394ee4e8481a8c9644d667ea99 Closes-bug: #1945239 --- hooks/cinder_contexts.py | 12 ++++++++++-- unit_tests/test_cinder_contexts.py | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/hooks/cinder_contexts.py b/hooks/cinder_contexts.py index 5c62893c..1e7f15e7 100644 --- a/hooks/cinder_contexts.py +++ b/hooks/cinder_contexts.py @@ -194,10 +194,18 @@ class CinderSubordinateConfigContext(SubordinateConfigContext): any_stateless = any_stateless or stateless if stateless: + + cmp_os_release = CompareOpenStackReleases( + os_release('cinder-common')) + clustering_config = ('cluster' if cmp_os_release >= "ocata" + else 'host') + if 'DEFAULT' in ctxt['sections']: - ctxt['sections']['DEFAULT'].append(('host', service_name())) + ctxt['sections']['DEFAULT'].append( + (clustering_config, service_name())) else: - ctxt['sections']['DEFAULT'] = [('host', service_name())] + ctxt['sections']['DEFAULT'] = [ + (clustering_config, service_name())] elif any_stateless: log("One or more stateless backends configured but unable to " diff --git a/unit_tests/test_cinder_contexts.py b/unit_tests/test_cinder_contexts.py index 87ba0929..cc958e01 100644 --- a/unit_tests/test_cinder_contexts.py +++ b/unit_tests/test_cinder_contexts.py @@ -312,6 +312,23 @@ class TestCinderContext(CharmTestCase): mock_rel_get.side_effect = fake_rel_get self.relation_get.side_effect = fake_rel_get + self.os_release.return_value = 'ocata' + + ctxt = contexts.CinderSubordinateConfigContext( + interface='storage-backend', + service='cinder', + config_file='/etc/cinder/cinder.conf')() + + exp = {'sections': {'DEFAULT': [('cluster', 'cinder')], + u'cinder-ceph': [[u'volume_backend_name', u'cinder-ceph'], + [u'volume_driver', + u'cinder.volume.drivers.rbd.RBDDriver'], + [u'rbd_pool', u'cinder-ceph'], + [u'rbd_user', u'cinder-ceph']]}} + + self.assertEqual(ctxt, exp) + + self.os_release.return_value = 'newton' ctxt = contexts.CinderSubordinateConfigContext( interface='storage-backend',