Add support for configuring sqlalchemy pool size, timeout and recycle
These are especially useful when using remote database servers. We need to be able to tweak when timeouts and recycling are occuring on the client side in order to prevent server-side timeouts to be happening. Change-Id: I7ced5ad644da212c80d9f3fcf0e3e1bad44e2e41
This commit is contained in:
parent
c406a9e0dd
commit
d72d911b61
|
@ -41,6 +41,24 @@ class BaseConfig(object):
|
|||
)
|
||||
self.SQLALCHEMY_DATABASE_URI = self.ARA_DATABASE
|
||||
self.SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
self.SQLALCHEMY_POOL_SIZE = ara_config(
|
||||
'sqlalchemy_pool_size',
|
||||
'SQLALCHEMY_POOL_SIZE',
|
||||
None,
|
||||
value_type='integer'
|
||||
)
|
||||
self.SQLALCHEMY_POOL_TIMEOUT = ara_config(
|
||||
'sqlalchemy_pool_timeout',
|
||||
'SQLALCHEMY_POOL_TIMEOUT',
|
||||
None,
|
||||
value_type='integer'
|
||||
)
|
||||
self.SQLALCHEMY_POOL_RECYCLE = ara_config(
|
||||
'sqlalchemy_pool_recycle',
|
||||
'SQLALCHEMY_POOL_RECYCLE',
|
||||
None,
|
||||
value_type='integer'
|
||||
)
|
||||
self.DB_MIGRATIONS = os.path.join(ara_location, 'db')
|
||||
|
||||
self.ARA_HOST = ara_config('host', 'ARA_HOST', '127.0.0.1')
|
||||
|
|
|
@ -34,24 +34,27 @@ class TestConfig(TestAra):
|
|||
# TODO: Improve those
|
||||
def test_config_base(self):
|
||||
base_config = BaseConfig()
|
||||
db = "sqlite:///%s/ansible.sqlite" % os.path.expanduser('~/.ara')
|
||||
db = 'sqlite:///%s/ansible.sqlite' % os.path.expanduser('~/.ara')
|
||||
defaults = {
|
||||
"FREEZER_IGNORE_MIMETYPE_WARNINGS": True,
|
||||
"FREEZER_DEFAULT_MIMETYPE": "text/html",
|
||||
"FREEZER_IGNORE_404_NOT_FOUND": True,
|
||||
"ARA_DIR": os.path.expanduser('~/.ara'),
|
||||
"SQLALCHEMY_DATABASE_URI": db,
|
||||
"ARA_HOST": "127.0.0.1",
|
||||
"ARA_AUTOCREATE_DATABASE": True,
|
||||
"ARA_PORT": "9191",
|
||||
"ARA_DATABASE": db,
|
||||
"ARA_IGNORE_EMPTY_GENERATION": True,
|
||||
"ARA_IGNORE_PARAMETERS": [
|
||||
"extra_vars"
|
||||
'FREEZER_IGNORE_MIMETYPE_WARNINGS': True,
|
||||
'FREEZER_DEFAULT_MIMETYPE': 'text/html',
|
||||
'FREEZER_IGNORE_404_NOT_FOUND': True,
|
||||
'ARA_DIR': os.path.expanduser('~/.ara'),
|
||||
'SQLALCHEMY_DATABASE_URI': db,
|
||||
'ARA_HOST': '127.0.0.1',
|
||||
'ARA_AUTOCREATE_DATABASE': True,
|
||||
'ARA_PORT': "9191",
|
||||
'ARA_DATABASE': db,
|
||||
'ARA_IGNORE_EMPTY_GENERATION': True,
|
||||
'ARA_IGNORE_PARAMETERS': [
|
||||
'extra_vars'
|
||||
],
|
||||
"FREEZER_RELATIVE_URLS": True,
|
||||
"SQLALCHEMY_TRACK_MODIFICATIONS": False,
|
||||
"DB_MIGRATIONS": os.path.join(ara_location, 'db')
|
||||
'FREEZER_RELATIVE_URLS': True,
|
||||
'SQLALCHEMY_TRACK_MODIFICATIONS': False,
|
||||
'SQLALCHEMY_POOL_SIZE': None,
|
||||
'SQLALCHEMY_POOL_TIMEOUT': None,
|
||||
'SQLALCHEMY_POOL_RECYCLE': None,
|
||||
'DB_MIGRATIONS': os.path.join(ara_location, 'db')
|
||||
}
|
||||
|
||||
for key, value in base_config.config.items():
|
||||
|
|
|
@ -139,6 +139,17 @@ Parameters and their defaults
|
|||
+-------------------------------+----------------------------+-------------------------------------------+
|
||||
| ARA_RESULT_PER_PAGE_ | result_per_page | 25 |
|
||||
+-------------------------------+----------------------------+-------------------------------------------+
|
||||
| SQLALCHEMY_POOL_SIZE_ | sqlalchemy_pool_size | None (default managed by flask-sqlalchemy)|
|
||||
+-------------------------------+----------------------------+-------------------------------------------+
|
||||
| SQLALCHEMY_POOL_TIMEOUT_ | sqlalchemy_pool_timeout | None (default managed by flask-sqlalchemy)|
|
||||
+-------------------------------+----------------------------+-------------------------------------------+
|
||||
| SQLALCHEMY_POOL_RECYCLE_ | sqlalchemy_pool_recycle | None (default managed by flask-sqlalchemy)|
|
||||
+-------------------------------+----------------------------+-------------------------------------------+
|
||||
|
||||
.. _SQLALCHEMY_POOL_SIZE: http://flask-sqlalchemy.pocoo.org/2.3/config/#configuration-keys
|
||||
.. _SQLALCHEMY_POOL_TIMEOUT: http://flask-sqlalchemy.pocoo.org/2.3/config/#configuration-keys
|
||||
.. _SQLALCHEMY_POOL_RECYCLE: http://flask-sqlalchemy.pocoo.org/2.3/config/#configuration-keys
|
||||
|
||||
|
||||
ARA_DIR
|
||||
~~~~~~~
|
||||
|
|
Loading…
Reference in New Issue