From b53c597b15b4a0d7f158da935825abb1d67e072d Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 11 Mar 2020 07:16:01 +0000 Subject: [PATCH] Do not run db updates if db is in maintenance mode As witih the shared-db hook do not run db updates if the database is in maintenace mode Closes-Bug: #1866864 Change-Id: I65619271d8a4215c8d9bf68ad0a86136ad87011c --- hooks/nova_cc_hooks.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hooks/nova_cc_hooks.py b/hooks/nova_cc_hooks.py index 01acb227..afefecac 100755 --- a/hooks/nova_cc_hooks.py +++ b/hooks/nova_cc_hooks.py @@ -317,13 +317,18 @@ def amqp_changed(): hookenv.log('amqp relation incomplete. Peer not ready?') return CONFIGS.write(ncc_utils.NOVA_CONF) - leader_init_db_if_ready_allowed_units() - # db init for cells v2 requires amqp transport_url and db connections - # to be set in nova.conf, so we attempt db init in here as well as the - # db relation-changed hooks. - update_cell_db_if_ready_allowed_units() + if ch_utils.is_db_maintenance_mode(): + hookenv.log( + 'Database maintenance mode, defering db updates.', + level=hookenv.DEBUG) + else: + leader_init_db_if_ready_allowed_units() + # db init for cells v2 requires amqp transport_url and db connections + # to be set in nova.conf, so we attempt db init in here as well as the + # db relation-changed hooks. + update_cell_db_if_ready_allowed_units() - update_child_cell_records() + update_child_cell_records() if hookenv.is_leader(): # NOTE: trigger restart on nova-api-metadata on