Do not rely on when_file_change for systemd reload
Systemd was not relying being reloaded when the definition file for aodh-api changed. The reload was supposed to be triggered by the when_file_changed decorator. However, there are a number of issues with when_file_changed decorator (*1, *2, *3) and the decorator has now been deprecated *4. This change ensures the reload happens without relying on the decorator. *1 https://github.com/juju-solutions/charms.reactive/issues/25 *2 https://github.com/juju-solutions/charms.reactive/issues/44 *3 https://github.com/juju-solutions/charms.reactive/issues/49 *4 https://github.com/juju-solutions/charms.reactive/issues/44#issuecomment-438472843 Closes-Bug: #1850767 Change-Id: I7c528a53a4de8a4a85bf655fc242b0f38fd0754b
This commit is contained in:
parent
3be96df033
commit
5050885df9
@ -85,7 +85,7 @@ class AodhCharm(charms_openstack.charm.HAOpenStackCharm):
|
||||
# file changes
|
||||
restart_map = {
|
||||
AODH_CONF: services,
|
||||
AODH_API_SYSTEMD_CONF: 'aodh-api',
|
||||
AODH_API_SYSTEMD_CONF: ['aodh-api'],
|
||||
}
|
||||
|
||||
# Resource when in HA mode
|
||||
@ -125,6 +125,23 @@ class AodhCharm(charms_openstack.charm.HAOpenStackCharm):
|
||||
ch_host.service_restart('aodh-api')
|
||||
|
||||
|
||||
class AodhCharmNewton(AodhCharm):
|
||||
"""Newton uses the aodh-api standalone systemd. If the systemd definition
|
||||
changes the a systemctl daemon-reload is needed.
|
||||
"""
|
||||
release = 'newton'
|
||||
|
||||
def render_with_interfaces(self, interface_list):
|
||||
if os.path.exists(AODH_API_SYSTEMD_CONF):
|
||||
old_hash = ch_host.file_hash(AODH_API_SYSTEMD_CONF)
|
||||
else:
|
||||
old_hash = ''
|
||||
super(AodhCharmNewton, self).render_with_interfaces(interface_list)
|
||||
new_hash = ch_host.file_hash(AODH_API_SYSTEMD_CONF)
|
||||
if old_hash != new_hash:
|
||||
self.reload_and_restart()
|
||||
|
||||
|
||||
class AodhCharmOcata(AodhCharm):
|
||||
"""From ocata onwards there is no aodh-api service, as this is handled via
|
||||
apache2 with a wsgi handler. Therefore, these specialisations are simple
|
||||
|
@ -103,9 +103,3 @@ def run_db_migration():
|
||||
@reactive.when('ha.connected')
|
||||
def cluster_connected(hacluster):
|
||||
aodh.configure_ha_resources(hacluster)
|
||||
|
||||
|
||||
# TODO: drop once charm switches to apache+mod_wsgi
|
||||
@reactive.when_file_changed(aodh.AODH_API_SYSTEMD_CONF)
|
||||
def systemd_override_changed():
|
||||
aodh.reload_and_restart()
|
||||
|
Loading…
Reference in New Issue
Block a user