Add retry for database migrations to deal with single shot ha deployments

This commit is contained in:
James Page 2015-03-10 15:16:32 +00:00
parent 6a7cc67908
commit 0d58f31ea7

View File

@ -53,6 +53,10 @@ from charmhelpers.contrib.network.ip import (
is_ipv6
)
from charmhelpers.core.decorators import (
retry_on_exception,
)
import nova_cc_context
TEMPLATES = 'templates/'
@ -566,6 +570,9 @@ def volume_service():
return 'cinder'
# NOTE(jamespage): Retry deals with sync issues during one-shot HA deploys.
# mysql might be restarting or suchlike.
@retry_on_exception(5, base_delay=3, exc_type=subprocess.CalledProcessError)
def migrate_nova_database():
'''Runs nova-manage to initialize a new database or migrate existing'''
log('Migrating the nova database.', level=INFO)
@ -579,6 +586,9 @@ def migrate_nova_database():
cmd_all_services('start')
# NOTE(jamespage): Retry deals with sync issues during one-shot HA deploys.
# mysql might be restarting or suchlike.
@retry_on_exception(5, base_delay=3, exc_type=subprocess.CalledProcessError)
def migrate_neutron_database():
'''Runs neutron-db-manage to init a new database or migrate existing'''
log('Migrating the neutron database.', level=INFO)