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
This commit is contained in:
Liam Young 2020-08-18 08:49:32 +00:00
parent 458af8aaf6
commit 25317a00cd
2 changed files with 18 additions and 4 deletions

View File

@ -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')

View File

@ -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')