diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 9e4cfad7..fd10ff84 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -324,6 +324,9 @@ def config_changed(): status_set('maintenance', 'Bootstrapping single Ceph MGR') ceph.bootstrap_manager() + for relid in relation_ids('dashboard'): + dashboard_relation(relid) + # Update client relations notify_client() @@ -871,6 +874,10 @@ def osd_relation(relid=None, unit=None): notify_client() notify_rbd_mirrors() send_osd_settings() + + for relid in relation_ids('dashboard'): + dashboard_relation(relid) + else: log('mon cluster not in quorum - deferring fsid provision') @@ -937,6 +944,17 @@ def ready_for_service(): return True +@hooks.hook('dashboard-relation-joined') +def dashboard_relation(relid=None): + """Inform dashboard that mons are ready""" + if not ready_for_service(): + log("mon cluster is not in quorum, dashboard notification skipped", + level=WARNING) + return + + relation_set(relation_id=relid, relation_settings={'mon-ready': True}) + + @hooks.hook('radosgw-relation-changed') @hooks.hook('radosgw-relation-joined') def radosgw_relation(relid=None, unit=None): diff --git a/hooks/dashboard-relation-joined b/hooks/dashboard-relation-joined new file mode 120000 index 00000000..52d96630 --- /dev/null +++ b/hooks/dashboard-relation-joined @@ -0,0 +1 @@ +ceph_hooks.py \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index 5c9e306d..f9aedfbb 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -40,6 +40,8 @@ provides: interface: ceph-rbd-mirror prometheus: interface: http + dashboard: + interface: ceph-dashboard requires: bootstrap-source: interface: ceph-bootstrap diff --git a/unit_tests/test_ceph_hooks.py b/unit_tests/test_ceph_hooks.py index ee4e8b4b..f5679a16 100644 --- a/unit_tests/test_ceph_hooks.py +++ b/unit_tests/test_ceph_hooks.py @@ -353,6 +353,24 @@ class CephHooksTestCase(test_utils.CharmTestCase): relation_settings={ 'nonce': 'FAKE-UUID'}) + @patch.object(ceph_hooks, 'relation_set') + @patch.object(ceph_hooks, 'ready_for_service') + def test_dashboard_relation(self, ready_for_service, relation_set): + ready_for_service.return_value = True + ceph_hooks.dashboard_relation() + relation_set.assert_called_once_with( + relation_id=None, + relation_settings={'mon-ready': True}) + relation_set.reset_mock() + ceph_hooks.dashboard_relation('rid1') + relation_set.assert_called_once_with( + relation_id='rid1', + relation_settings={'mon-ready': True}) + ready_for_service.return_value = False + relation_set.reset_mock() + ceph_hooks.dashboard_relation() + self.assertFalse(relation_set.called) + @patch.object(ceph_hooks.hookenv, 'remote_service_name') @patch.object(ceph_hooks, 'relation_get') @patch.object(ceph_hooks, 'remote_unit')