Fix restart when endpoint notification is received

Restarts were configured only when the ceilometer agent endpoint
had changed and only alarm services were triggered to be restarted.
This change adds a check for the gnocchi service having changed
too and restarts all services to be on the safe side.

Closes-Bug: #1867924
Change-Id: I48e2f079e2db640d485bc74bfc2cedfd7e82ac84
This commit is contained in:
Liam Young 2020-08-20 09:10:18 +00:00
parent 7c0ecdbd1a
commit e3982a2d98
3 changed files with 15 additions and 6 deletions

View File

@ -91,6 +91,7 @@ from ceilometer_utils import (
services,
get_ceilometer_context,
get_shared_secret,
GNOCCHI_SERVICE,
do_openstack_upgrade,
set_shared_secret,
assess_status,
@ -426,10 +427,16 @@ def identity_notifications_changed():
# Some ceilometer services will create a client and request
# the service catalog from keystone on startup. So if
# endpoints change we need to restart these services.
key = '%s-endpoint-changed' % (CEILOMETER_SERVICE)
if key in notifications:
service_restart('ceilometer-alarm-evaluator')
service_restart('ceilometer-alarm-notifier')
restart_needed = False
for svc in [CEILOMETER_SERVICE, GNOCCHI_SERVICE]:
key = '%s-endpoint-changed' % (svc)
if key in notifications:
log('Change of endpoint {} detected, '
'trigger service restart'.format(svc))
restart_needed = True
if restart_needed:
for restart_svc in services():
service_restart(restart_svc)
@hooks.hook("ceilometer-service-relation-joined")

View File

@ -107,6 +107,7 @@ MITAKA_SERVICES = [
CEILOMETER_DB = "ceilometer"
CEILOMETER_SERVICE = "ceilometer"
GNOCCHI_SERVICE = "gnocchi"
CEILOMETER_BASE_PACKAGES = [
'haproxy',

View File

@ -331,6 +331,7 @@ class CeilometerHooksTest(CharmTestCase):
@patch('charmhelpers.core.hookenv.config')
def test_identity_notifications_changed(self, mock_config):
self.services.return_value = ['svc1', 'svc2']
self.relation_ids.return_value = ['keystone-notifications:0']
self.relation_get.return_value = None
@ -340,8 +341,8 @@ class CeilometerHooksTest(CharmTestCase):
(hooks.CEILOMETER_SERVICE)): 1}
hooks.hooks.execute(['hooks/identity-notifications-relation-changed'])
call1 = call('ceilometer-alarm-evaluator')
call2 = call('ceilometer-alarm-notifier')
call1 = call('svc1')
call2 = call('svc2')
self.service_restart.assert_has_calls([call1, call2], any_order=False)
@patch('charmhelpers.core.hookenv.config')