Browse Source

Bugfix: 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.

Backported from train

Change-Id: I14a2fb643d04cad2f6ef3ab7a80b7e7c63224f74
changes/89/715889/1
Idan Hefetz 3 months ago
parent
commit
66b6dd4879
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      vitrage/storage/__init__.py

+ 6
- 2
vitrage/storage/__init__.py View File

@@ -45,11 +45,15 @@ def get_connection_from_config(conf):

@tenacity.retry(
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)
def _get_connection():
"""Return an open connection to the database."""
return mgr.driver(conf, url)
conn = mgr.driver(conf, url)
session = conn._engine_facade.get_session()
session.execute('SELECT 1;')
return conn

return _get_connection()



Loading…
Cancel
Save