From 25317a00cd08c3ddd1dbc2015ab2b33c71316359 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Tue, 18 Aug 2020 08:49:32 +0000 Subject: [PATCH] Update to work with changes to interface. The ceph-mds interface has been updated to work in the same way as the ceph-client interface. This requires some minor updates to the charm so pools are requested when the ceph cluster is first available and the service is configured once the pools have been confirmed to exist. Depends-On: I9f438bb678da1b69d8161390aad2cf58907bc1b5 Change-Id: I83148f73c7f0465ecfadaa9df92e4a53e30813de --- src/reactive/ceph_fs.py | 13 +++++++++++-- unit_tests/test_reactive_ceph_fs.py | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/reactive/ceph_fs.py b/src/reactive/ceph_fs.py index 9c54bdc..215d908 100644 --- a/src/reactive/ceph_fs.py +++ b/src/reactive/ceph_fs.py @@ -13,6 +13,7 @@ # limitations under the License. from charms import reactive +from charmhelpers.core import hookenv import charms_openstack.bus import charms_openstack.charm as charm @@ -31,9 +32,9 @@ charm.use_defaults( @reactive.when_none('charm.paused', 'run-default-update-status') -@reactive.when('ceph-mds.available') +@reactive.when('ceph-mds.pools.available') def config_changed(): - ceph_mds = reactive.endpoint_from_flag('ceph-mds.available') + ceph_mds = reactive.endpoint_from_flag('ceph-mds.pools.available') with charm.provide_charm_instance() as cephfs_charm: cephfs_charm.configure_ceph_keyring(ceph_mds.mds_key()) cephfs_charm.render_with_interfaces([ceph_mds]) @@ -45,3 +46,11 @@ def config_changed(): reactive.set_flag('cephfs.configured') reactive.set_flag('config.rendered') cephfs_charm.assess_status() + + +@reactive.when_not('ceph.create_pool.req.sent') +@reactive.when('ceph-mds.connected') +def storage_ceph_connected(ceph): + ceph.announce_mds_name() + ceph.initialize_mds(hookenv.service_name()) + reactive.set_state('ceph.create_pool.req.sent') diff --git a/unit_tests/test_reactive_ceph_fs.py b/unit_tests/test_reactive_ceph_fs.py index c210afe..1499959 100644 --- a/unit_tests/test_reactive_ceph_fs.py +++ b/unit_tests/test_reactive_ceph_fs.py @@ -32,7 +32,11 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks): ] hook_set = { 'when': { - 'config_changed': ('ceph-mds.available',), + 'config_changed': ('ceph-mds.pools.available',), + 'storage_ceph_connected': ('ceph-mds.connected',), + }, + 'when_not': { + 'storage_ceph_connected': ('ceph.create_pool.req.sent',), }, 'when_none': { 'config_changed': ('charm.paused', @@ -65,7 +69,8 @@ class TestCephFSHandlers(test_utils.PatchHelper): self.endpoint_from_flag.return_value = ceph_mds self.is_flag_set.return_value = False handlers.config_changed() - self.endpoint_from_flag.assert_called_once_with('ceph-mds.available') + self.endpoint_from_flag.assert_called_once_with( + 'ceph-mds.pools.available') self.target.configure_ceph_keyring.assert_called_once_with('fakekey') self.target.render_with_interfaces.assert_called_once_with([ceph_mds]) self.is_flag_set.assert_called_once_with('config.changed.source')