From 026233bd7c36606861961c946b46694d1f0d54e2 Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Tue, 27 Oct 2020 12:45:46 +0000 Subject: [PATCH] Add 'rbd-mirroring-mode' to replicated 'create-pool' broker req op The new config option is applied only to the broker request to create the charm replicated pool. Co-authored-by: Marius Oprin Change-Id: I6bf9544af02d0622b8f714da97b5dbcf49d1d1af --- config.yaml | 7 +++++++ hooks/cinder_hooks.py | 1 + unit_tests/test_cinder_hooks.py | 10 +++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index 9b8190d..aa0d6da 100644 --- a/config.yaml +++ b/config.yaml @@ -53,6 +53,13 @@ options: description: | Flatten volumes created from snapshots to remove dependency from volume to snapshot. Supported on Queens+ + rbd-mirroring-mode: + type: string + default: pool + description: | + The RBD mirroring mode used for the Ceph pool. This option is only used + with 'replicated' pool type, as it's not supported for 'erasure-coded' + pool type - valid values: 'pool' and 'image' pool-type: type: string default: replicated diff --git a/hooks/cinder_hooks.py b/hooks/cinder_hooks.py index 9f44857..891ce81 100755 --- a/hooks/cinder_hooks.py +++ b/hooks/cinder_hooks.py @@ -193,6 +193,7 @@ def get_ceph_request(): 'weight': weight, 'group': 'volumes', 'app_name': 'rbd', + 'rbd_mirroring_mode': config('rbd-mirroring-mode') } kwargs.update(bluestore_compression.get_kwargs()) rq.add_op_create_replicated_pool(**kwargs) diff --git a/unit_tests/test_cinder_hooks.py b/unit_tests/test_cinder_hooks.py index f716128..ecae0bb 100644 --- a/unit_tests/test_cinder_hooks.py +++ b/unit_tests/test_cinder_hooks.py @@ -141,14 +141,16 @@ class TestCinderHooks(CharmTestCase): hooks.get_ceph_request() mock_create_pool.assert_called_with(name='cinder', replica_count=4, weight=20, group='volumes', - app_name='rbd') + app_name='rbd', + rbd_mirroring_mode='pool') mock_request_access.assert_not_called() self.test_config.set('restrict-ceph-pools', True) hooks.get_ceph_request() mock_create_pool.assert_called_with(name='cinder', replica_count=4, weight=20, group='volumes', - app_name='rbd') + app_name='rbd', + rbd_mirroring_mode='pool') mock_request_access.assert_has_calls([ call( name='volumes', @@ -181,7 +183,8 @@ class TestCinderHooks(CharmTestCase): replica_count=4, weight=20, group='volumes', - app_name='rbd') + app_name='rbd', + rbd_mirroring_mode='pool') # confirm operation with bluestore compression mock_create_pool.reset_mock() mock_bluestore_compression().get_kwargs.return_value = { @@ -193,6 +196,7 @@ class TestCinderHooks(CharmTestCase): weight=20, group='volumes', app_name='rbd', + rbd_mirroring_mode='pool', compression_mode='fake') @patch.object(hooks, 'CephBlueStoreCompressionContext')