Overcome mysql failure during Vitrage init.
Test the connection to detect mysql failures before executing statements. It is better to fail early because at that point we have retries. Change-Id: I9f358104b173920c279bf1213a76518f4b7bb5b5
This commit is contained in:
parent
e71b5a45de
commit
8c027ee36e
@ -46,11 +46,15 @@ def get_connection_from_config():
|
|||||||
|
|
||||||
@tenacity.retry(
|
@tenacity.retry(
|
||||||
wait=tenacity.wait_fixed(CONF.database.retry_interval),
|
wait=tenacity.wait_fixed(CONF.database.retry_interval),
|
||||||
stop=tenacity.stop_after_attempt(retries if retries >= 0 else 5),
|
stop=tenacity.stop_after_attempt(retries),
|
||||||
|
after=tenacity.after_log(LOG, log.WARN),
|
||||||
reraise=True)
|
reraise=True)
|
||||||
def _get_connection():
|
def _get_connection():
|
||||||
"""Return an open connection to the database."""
|
"""Return an open connection to the database."""
|
||||||
return mgr.driver(url)
|
conn = mgr.driver(url)
|
||||||
|
session = conn._engine_facade.get_session()
|
||||||
|
session.execute('SELECT 1;')
|
||||||
|
return conn
|
||||||
|
|
||||||
return _get_connection()
|
return _get_connection()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user