From 14f6f2885bf763082bd64f03c9b258b38afaff79 Mon Sep 17 00:00:00 2001 From: Nobuto Murata Date: Mon, 28 Aug 2017 23:51:45 +0700 Subject: [PATCH] Use proper ceph.conf generated by ceph-backup relation When a primary Ceph cluster is used as a volume backend and a secondary cluster as a backup backend, target Ceph mon addresses will be different. But previously both Cinder volume and backup services use the same /etc/ceph/ceph.conf generated by cinder-ceph and ceph-mon relation. Instead, use separete ceph.conf files based on relation types. Change-Id: I1d82db179b41b0c01d2a217838384ac71ef7bdad Closes-Bug: #1713489 --- hooks/cinder_backup_contexts.py | 5 +++++ tests/basic_deployment.py | 2 ++ unit_tests/test_cinder_backup_contexts.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/hooks/cinder_backup_contexts.py b/hooks/cinder_backup_contexts.py index ec96286..74fea97 100644 --- a/hooks/cinder_backup_contexts.py +++ b/hooks/cinder_backup_contexts.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + from charmhelpers.core.hookenv import ( service_name, is_relation_made, @@ -47,6 +49,9 @@ class CephBackupSubordinateContext(OSContextGenerator): "sections": { 'DEFAULT': [ ('backup_driver', backup_driver), + ('backup_ceph_conf', + os.path.join('/var/lib/charm', + service, 'ceph.conf')), ('backup_ceph_pool', service), ('backup_ceph_user', service), ] diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 1cc9516..70c7e43 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -400,6 +400,8 @@ class CinderBackupBasicDeployment(OpenStackAmuletDeployment): sub = ('{"cinder": {"/etc/cinder/cinder.conf": {"sections": ' '{"DEFAULT": [' '["backup_driver", "cinder.backup.drivers.ceph"], ' + '["backup_ceph_conf", ' + '"/var/lib/charm/cinder-backup/ceph.conf"], ' '["backup_ceph_pool", "cinder-backup"], ' '["backup_ceph_user", "cinder-backup"]]}}}}') expected = { diff --git a/unit_tests/test_cinder_backup_contexts.py b/unit_tests/test_cinder_backup_contexts.py index b7386f9..250332c 100644 --- a/unit_tests/test_cinder_backup_contexts.py +++ b/unit_tests/test_cinder_backup_contexts.py @@ -38,6 +38,9 @@ class TestCinderBackupContext(CharmTestCase): {'sections': {'DEFAULT': [('backup_driver', 'cinder.backup.drivers.ceph'), + ('backup_ceph_conf', + '/var/lib/charm/' + 'cinder-backup-ut/ceph.conf'), ('backup_ceph_pool', 'cinder-backup-ut'), ('backup_ceph_user',