summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-08 19:12:08 +0000
committerGerrit Code Review <review@openstack.org>2019-03-08 19:12:08 +0000
commit3c73474c0775ad21712c86502096a5ce64e5ac35 (patch)
tree52a53a788dc633e8bc37d39fdf058be85e1eb339
parent0a24b01e89a801e5ef19184f76864b12d3e66d50 (diff)
parent41298d51ad745d52dac3f629a31cbd6b2fff82cf (diff)
Merge "SQL: only create tables in scheduler"
-rw-r--r--zuul/driver/sql/sqlconnection.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/zuul/driver/sql/sqlconnection.py b/zuul/driver/sql/sqlconnection.py
index c99187f..96a8762 100644
--- a/zuul/driver/sql/sqlconnection.py
+++ b/zuul/driver/sql/sqlconnection.py
@@ -187,7 +187,6 @@ class SQLConnection(BaseConnection):
187 self.dburi, 187 self.dburi,
188 poolclass=sqlalchemy.pool.QueuePool, 188 poolclass=sqlalchemy.pool.QueuePool,
189 pool_recycle=self.connection_config.get('pool_recycle', 1)) 189 pool_recycle=self.connection_config.get('pool_recycle', 1))
190 self._migrate()
191 190
192 # If we want the objects returned from query() to be 191 # If we want the objects returned from query() to be
193 # usable outside of the session, we need to expunge them 192 # usable outside of the session, we need to expunge them
@@ -200,7 +199,6 @@ class SQLConnection(BaseConnection):
200 autoflush=False) 199 autoflush=False)
201 self.session = orm.scoped_session(self.session_factory) 200 self.session = orm.scoped_session(self.session_factory)
202 201
203 self.tables_established = True
204 except sa.exc.NoSuchModuleError: 202 except sa.exc.NoSuchModuleError:
205 self.log.exception( 203 self.log.exception(
206 "The required module for the dburi dialect isn't available. " 204 "The required module for the dburi dialect isn't available. "
@@ -231,6 +229,20 @@ class SQLConnection(BaseConnection):
231 tag = {'table_prefix': self.table_prefix} 229 tag = {'table_prefix': self.table_prefix}
232 alembic.command.upgrade(config, 'head', tag=tag) 230 alembic.command.upgrade(config, 'head', tag=tag)
233 231
232 def onLoad(self):
233 try:
234 self._migrate()
235 self.tables_established = True
236 except sa.exc.NoSuchModuleError:
237 self.log.exception(
238 "The required module for the dburi dialect isn't available. "
239 "SQL connection %s will be unavailable." %
240 self.connection_name)
241 except sa.exc.OperationalError:
242 self.log.exception(
243 "Unable to connect to the database or establish the required "
244 "tables. Connection %s is disabled" % self)
245
234 def _setup_models(self): 246 def _setup_models(self):
235 Base = declarative_base(metadata=sa.MetaData()) 247 Base = declarative_base(metadata=sa.MetaData())
236 248