Disable designate-mdns service until the configuration has been rendered

As per the bug report, designate-mdns service appear to restart multiple time.
This patch disable the service until the configuration has been rendered.

Closes-Bug: #1925233
Change-Id: Ib9843bda9c6967ce50cec8d721079bd70f7f3040
This commit is contained in:
Francesco de Simone 2022-06-29 20:53:16 +00:00 committed by fdesi
parent fc616b48c0
commit 1fef3793f5
2 changed files with 32 additions and 1 deletions

View File

@ -90,6 +90,32 @@ def setup_amqp_req(amqp):
vhost='openstack') vhost='openstack')
@reactive.when('base-config.rendered')
@reactive.when_not('config.rendered')
def config_rendered():
"""Set the config.rendered state when ready for operation.
The config.rendered flag is used by the default handlers in
charms.openstack to enable/disable services based on the
readiness of the deployment. This functionality ensure
that the Designate services start up only after the
database has been synced.
LP#1925233
"""
reactive.set_state('config.rendered')
@reactive.when('config.rendered', 'base-config.rendered')
def start_designate_services():
"""Enable services when database is synchronized"""
with charm.provide_charm_instance() as instance:
if instance.db_sync_done():
instance.enable_services()
else:
hookenv.log("Services not enabled, waiting for db sync",
level=hookenv.WARNING)
@reactive.when('shared-db.connected') @reactive.when('shared-db.connected')
@reactive.when_not('shared-db.setup') @reactive.when_not('shared-db.setup')
def setup_database(database): def setup_database(database):
@ -128,7 +154,7 @@ def expose_rndc_address(cluster):
@reactive.when_not('base-config.rendered') @reactive.when_not('base-config.rendered')
@reactive.when(*COMPLETE_INTERFACE_STATES) @reactive.when(*COMPLETE_INTERFACE_STATES)
def configure_designate_basic(*args): def configure_designate_basic(*args):
"""Configure the minimum to boostrap designate""" """Configure the minimum to bootstrap designate"""
# If cluster relation is available it needs to passed in # If cluster relation is available it needs to passed in
cluster = relations.endpoint_from_flag('cluster.available') cluster = relations.endpoint_from_flag('cluster.available')
if cluster is not None: if cluster is not None:
@ -138,6 +164,7 @@ def configure_designate_basic(*args):
args = args + (dns_backend, ) args = args + (dns_backend, )
with charm.provide_charm_instance() as instance: with charm.provide_charm_instance() as instance:
instance.render_base_config(args) instance.render_base_config(args)
instance.disable_services()
reactive.set_state('base-config.rendered') reactive.set_state('base-config.rendered')

View File

@ -22,7 +22,10 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'setup_amqp_req': ('amqp.connected', ), 'setup_amqp_req': ('amqp.connected', ),
'setup_database': ('shared-db.connected', ), 'setup_database': ('shared-db.connected', ),
'maybe_setup_endpoint': ('identity-service.connected', ), 'maybe_setup_endpoint': ('identity-service.connected', ),
'start_designate_services': ('config.rendered',
'base-config.rendered', ),
'expose_rndc_address': ('cluster.connected', ), 'expose_rndc_address': ('cluster.connected', ),
'config_rendered': ('base-config.rendered', ),
'configure_ssl': ('identity-service.available', ), 'configure_ssl': ('identity-service.available', ),
'config_changed': ('config.changed', ), 'config_changed': ('config.changed', ),
'cluster_connected': ('ha.connected', ), 'cluster_connected': ('ha.connected', ),
@ -45,6 +48,7 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'when_not': { 'when_not': {
'setup_amqp_req': ('amqp.requested-access', ), 'setup_amqp_req': ('amqp.requested-access', ),
'setup_database': ('shared-db.setup', ), 'setup_database': ('shared-db.setup', ),
'config_rendered': ('config.rendered', ),
'install_packages': ('installed', ), 'install_packages': ('installed', ),
'run_db_migration': ('db.synched', ), 'run_db_migration': ('db.synched', ),
'sync_pool_manager_cache': ('pool-manager-cache.synched', ), 'sync_pool_manager_cache': ('pool-manager-cache.synched', ),