Prevent update-status to run unrequired handlers

Before, the update-status hook would run many handlers
that would have been normally done only during
configuration changes.
Consequently it creates an impact on the service and
apply changes every time the hook is triggered, which is
in most deployments every 5 minutes.
This prevents the DNS zones managed by Designate to be
updated constantly and potentially avoid race conditions
within designate components.

Closes-bug: #2003528
Change-Id: I0d4fea182da1316c0c30c143e64fcd2ca682afff
This commit is contained in:
Olivier Dufour-Cuvillier 2023-01-30 19:38:02 +09:00 committed by Nobuto Murata
parent ea0c1da551
commit f84cee2634
2 changed files with 16 additions and 1 deletions

View File

@ -59,6 +59,7 @@ def check_dns_slaves():
reactive.remove_state('dns-slaves-config-valid')
@reactive.when_not('is-update-status-hook')
@reactive.when_any('dns-slaves-config-valid',
'dns-backend.available')
def set_dns_config_available(*args):
@ -83,6 +84,7 @@ def install_packages():
reactive.remove_state('pool-manager-cache.synched')
@reactive.when_not('is-update-status-hook')
@reactive.when('amqp.connected')
def setup_amqp_req(amqp):
"""Send request for rabbit access and vhost"""
@ -105,6 +107,7 @@ def config_rendered():
reactive.set_state('config.rendered')
@reactive.when_not('is-update-status-hook')
@reactive.when_none('charm.paused')
@reactive.when('config.rendered', 'base-config.rendered')
def start_designate_services():
@ -132,6 +135,7 @@ def setup_database(database):
reactive.set_state('shared-db.setup')
@reactive.when_not('is-update-status-hook')
@reactive.when('identity-service.connected')
def maybe_setup_endpoint(keystone):
"""When the keystone interface connects, register this unit in the keystone
@ -146,6 +150,7 @@ def maybe_setup_endpoint(keystone):
keystone.register_endpoints(*args)
@reactive.when_not('is-update-status-hook')
@reactive.when('cluster.connected')
def expose_rndc_address(cluster):
rndc_address = ip.get_relation_ip('dns-backend')
@ -190,6 +195,7 @@ def sync_pool_manager_cache(*args):
reactive.set_state('pool-manager-cache.synched')
@reactive.when_not('is-update-status-hook')
@reactive.when('db.synched')
@reactive.when('pool-manager-cache.synched')
@reactive.when(*COMPLETE_INTERFACE_STATES)
@ -232,6 +238,7 @@ def _render_sink_configs(instance, interfaces_list):
instance.render_with_interfaces(interfaces_list, configs=configs)
@reactive.when_not('is-update-status-hook')
@reactive.when('ha.connected')
def cluster_connected(hacluster):
"""Configure HA resources in corosync"""
@ -239,6 +246,7 @@ def cluster_connected(hacluster):
instance.configure_ha_resources(hacluster)
@reactive.when_not('is-update-status-hook')
@reactive.when('dnsaas.connected')
def expose_endpoint(endpoint):
with charm.provide_charm_instance() as instance:

View File

@ -46,7 +46,7 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'configure_nrpe': ('base-config.rendered', ),
},
'when_not': {
'setup_amqp_req': ('amqp.requested-access', ),
'setup_amqp_req': ('is-update-status-hook', ),
'setup_database': ('shared-db.setup', ),
'config_rendered': ('config.rendered', ),
'install_packages': ('installed', ),
@ -58,6 +58,13 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'dont-set-assess-status', ),
'reset_shared_db': ('shared-db.connected', ),
'configure_nrpe': ('is-update-status-hook', ),
'set_dns_config_available': ('is-update-status-hook', ),
'start_designate_services': ('is-update-status-hook', ),
'maybe_setup_endpoint': ('is-update-status-hook', ),
'expose_endpoint': ('is-update-status-hook', ),
'configure_designate_full': ('is-update-status-hook', ),
'expose_rndc_address': ('is-update-status-hook', ),
'cluster_connected': ('is-update-status-hook', ),
},
'when_any': {
'set_dns_config_available': (