Remove nrpe check of nova-consoleauth when not needed.

nova-consoleauth was removed for OpenStack >= Train, this change will
remove the nrpe check associated with it when is_consoleauth_enabled()
returns False.

Change-Id: I891634fc8001597089312801b29a80336543f5f0
Closes-Bug: #1904650
This commit is contained in:
Felipe Reyes 2021-12-17 17:46:51 -03:00
parent 68a124df5d
commit bebed44c3b
3 changed files with 32 additions and 0 deletions

View File

@ -1255,6 +1255,8 @@ def update_nrpe_config():
ncc_utils.services(),
current_unit)
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
if not ncc_utils.is_consoleauth_enabled():
nrpe_setup.remove_check(shortname='nova-consoleauth')
nrpe_setup.write()

View File

@ -1324,3 +1324,21 @@ class NovaCCHooksTests(CharmTestCase):
compute_joined.assert_has_calls([
call(rid='ridcomp7', remote_restart=True),
call(rid='ridcomp9', remote_restart=True)], any_order=True)
@patch('charmhelpers.contrib.charmsupport.nrpe.NRPE.remove_check')
@patch('charmhelpers.contrib.charmsupport.nrpe.copy_nrpe_checks')
@patch('charmhelpers.contrib.charmsupport.nrpe.config')
@patch('charmhelpers.contrib.charmsupport.nrpe.relation_ids')
@patch('charmhelpers.contrib.charmsupport.nrpe.local_unit')
def test_update_nrpe_config(self,
mock_local_unit,
mock_relation_ids,
mock_config,
mock_copy_nrpe_checks,
mock_remove_check):
self.os_release.return_value = 'train'
self.config.side_effect = self.test_config
mock_config.return_value = self.test_config
hooks.update_nrpe_config()
mock_remove_check.assert_called_with(shortname='nova-consoleauth')

View File

@ -120,6 +120,18 @@ class TestConfig(object):
for k, v in d.items():
self.set(k, v)
def __getitem__(self, key):
return self.get(key)
def __contains__(self, key):
return key in self.config
def __call__(self, key=None):
if key:
return self.get(key)
else:
return self
class TestRelation(object):