Display information if missing OSD relation

When ceph-mon is blocked on waiting for enough OSDs to be available,
it will display a message to that effect.
But this is misleading if ceph-mon has not been related to ceph-osd.
So if the two are not related,
and ceph-mon is waiting for OSDS,
then display a message about the relation missing.

Closes-Bug: #1886558
Change-Id: Ic5ee9d33d2bb874af7fc7c325773f88c5661fcc6
This commit is contained in:
Samuel Walladge 2022-01-13 07:42:39 +10:30
parent 6ab445a87e
commit 48c52fafdd
2 changed files with 50 additions and 0 deletions

View File

@ -1296,6 +1296,8 @@ def assess_status():
expected_osd_count = config('expected-osd-count') or 3
if sufficient_osds(expected_osd_count):
status_set('active', 'Unit is ready and clustered')
elif not relation_ids('osd'):
status_set('blocked', 'Missing relation: OSD')
else:
status_set(
'waiting',

View File

@ -102,6 +102,54 @@ class ServiceStatusTestCase(test_utils.CharmTestCase):
self.status_set.assert_called_with('active', mock.ANY)
self.application_version_set.assert_called_with('10.2.2')
@mock.patch.object(hooks, 'relation_ids')
@mock.patch.object(hooks, 'get_osd_settings')
@mock.patch.object(hooks, 'has_rbd_mirrors')
@mock.patch.object(hooks, 'sufficient_osds')
@mock.patch.object(hooks, 'get_peer_units')
def test_assess_status_no_osd_relation(
self,
_peer_units,
_sufficient_osds,
_has_rbd_mirrors,
_get_osd_settings,
_relation_ids
):
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
_sufficient_osds.return_value = False
_relation_ids.return_value = []
self.ceph.is_bootstrapped.return_value = True
self.ceph.is_quorum.return_value = True
_has_rbd_mirrors.return_value = False
_get_osd_settings.return_value = {}
hooks.assess_status()
self.status_set.assert_called_with('blocked', 'Missing relation: OSD')
self.application_version_set.assert_called_with('10.2.2')
@mock.patch.object(hooks, 'relation_ids')
@mock.patch.object(hooks, 'get_osd_settings')
@mock.patch.object(hooks, 'has_rbd_mirrors')
@mock.patch.object(hooks, 'sufficient_osds')
@mock.patch.object(hooks, 'get_peer_units')
def test_assess_status_osd_relation_but_insufficient_osds(
self,
_peer_units,
_sufficient_osds,
_has_rbd_mirrors,
_get_osd_settings,
_relation_ids
):
_peer_units.return_value = ENOUGH_PEERS_COMPLETE
_sufficient_osds.return_value = False
_relation_ids.return_value = ['osd:1']
self.ceph.is_bootstrapped.return_value = True
self.ceph.is_quorum.return_value = True
_has_rbd_mirrors.return_value = False
_get_osd_settings.return_value = {}
hooks.assess_status()
self.status_set.assert_called_with('waiting', mock.ANY)
self.application_version_set.assert_called_with('10.2.2')
@mock.patch.object(hooks, 'get_osd_settings')
@mock.patch.object(hooks, 'has_rbd_mirrors')
@mock.patch.object(hooks, 'sufficient_osds')