Setup model before connection

In case connection has issue we don't have the model set and accessing
it using "builds" web renders "Loading...", let's create the empty model
so it shows an empty table.

Change-Id: I247cbc0ebcbd94851d9c80366859ddf8b776be57
This commit is contained in:
Quique Llorente 2018-11-16 09:27:15 +01:00
parent 71f60674b9
commit 0482e1e6b2
1 changed files with 3 additions and 2 deletions

View File

@ -47,6 +47,9 @@ class SQLConnection(BaseConnection):
try:
self.dburi = self.connection_config.get('dburi')
self.zuul_buildset_table, self.zuul_build_table \
= self._setup_models()
# Recycle connections if they've been idle for more than 1 second.
# MySQL connections are lightweight and thus keeping long-lived
# connections around is not valuable.
@ -55,8 +58,6 @@ class SQLConnection(BaseConnection):
poolclass=sqlalchemy.pool.QueuePool,
pool_recycle=self.connection_config.get('pool_recycle', 1))
self._migrate()
self.zuul_buildset_table, self.zuul_build_table \
= self._setup_models()
self.tables_established = True
except sa.exc.NoSuchModuleError:
self.log.exception(