From f9654dce7d2b36e702f705da5e93899e78675fdd Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 16 Oct 2017 07:56:52 +0000 Subject: [PATCH] Add LVM as default backend This change set the enable-backends cinder config option to the package default of 'lvm'. The reason is to stop the service flapping and fix the bug which is causing cinder-volume service to be down in some deployments. Change-Id: I29b9bccf75019b73f60c1160b8b6c7cb11d3ad28 Closes-Bug: 1719742 --- .gitignore | 1 + hooks/cinder_contexts.py | 12 ++++++------ unit_tests/test_cinder_contexts.py | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 8b9560ff..45f9daaf 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ bin *.sw[nop] *.pyc .unit-state.db +.stestr diff --git a/hooks/cinder_contexts.py b/hooks/cinder_contexts.py index 5893a37d..d0e60802 100644 --- a/hooks/cinder_contexts.py +++ b/hooks/cinder_contexts.py @@ -137,12 +137,12 @@ class StorageBackendContext(OSContextGenerator): backends.append('CEPH') if enable_lvm(): backends.append('LVM') - if len(backends) > 0: - return { - 'active_backends': backends, - 'backends': ",".join(backends)} - else: - return {} + # Use the package default backend to stop the service flapping. + if not backends: + backends = ['LVM'] + return { + 'active_backends': backends, + 'backends': ",".join(backends)} class LoggingConfigContext(OSContextGenerator): diff --git a/unit_tests/test_cinder_contexts.py b/unit_tests/test_cinder_contexts.py index f56d07ca..6880fc1e 100644 --- a/unit_tests/test_cinder_contexts.py +++ b/unit_tests/test_cinder_contexts.py @@ -113,7 +113,9 @@ class TestCinderContext(CharmTestCase): self.config.return_value = None self.relation_ids.return_value = [] self.os_release.return_value = 'havana' - self.assertEqual(contexts.StorageBackendContext()(), {}) + self.assertEqual( + contexts.StorageBackendContext()(), + {'active_backends': ['LVM'], 'backends': 'LVM'}) def test_storage_backend_single_backend(self): rel_dict = {