Set DB retry for quota_enforcement pecan_wsgi hook
The hook starts a DB transaction and should be covered with DB retry decorator. For Rocky backport had to import neutron_lib.db for retry_db_errors. Closes-Bug: #1777965 Closes-Bug: #1771293 Change-Id: I044980a98845edc7b0a02e3323a1e62eb54c10c7 (cherry picked from commitab286bcdac
) (cherry picked from commit3ec7aed8a3
)
This commit is contained in:
parent
2a81f9879d
commit
22250e783b
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
from neutron_lib.db import api as nlib_db_api
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from pecan import hooks
|
from pecan import hooks
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ class QuotaEnforcementHook(hooks.PecanHook):
|
|||||||
# retrieved in the 'after' hook
|
# retrieved in the 'after' hook
|
||||||
state.request.context['reservations'] = reservations
|
state.request.context['reservations'] = reservations
|
||||||
|
|
||||||
|
@nlib_db_api.retry_db_errors
|
||||||
def after(self, state):
|
def after(self, state):
|
||||||
neutron_context = state.request.context.get('neutron_context')
|
neutron_context = state.request.context.get('neutron_context')
|
||||||
if not neutron_context:
|
if not neutron_context:
|
||||||
|
@ -61,11 +61,6 @@ def set_resources_dirty(context):
|
|||||||
dirty status is True, sets the dirty bit to True in the database
|
dirty status is True, sets the dirty bit to True in the database
|
||||||
for the appropriate tenants.
|
for the appropriate tenants.
|
||||||
|
|
||||||
Please note that this routine begins a nested transaction, and it
|
|
||||||
is not recommended that this transaction begins within another
|
|
||||||
transaction. For this reason the function will raise a SqlAlchemy
|
|
||||||
exception if such an attempt is made.
|
|
||||||
|
|
||||||
:param context: a Neutron request context with a DB session
|
:param context: a Neutron request context with a DB session
|
||||||
"""
|
"""
|
||||||
if not cfg.CONF.QUOTAS.track_quota_usage:
|
if not cfg.CONF.QUOTAS.track_quota_usage:
|
||||||
|
Loading…
Reference in New Issue
Block a user