Fix quota error messages

The quota error/warning messages displayed type(_class) which was
translated to <class 'type'>. Now the messages are fixed and display
helpful logs:
  Quota decrement on <class 'octavia.common.data_models.L7Policy'> called
  on project

Related-Bug: #2015050

Change-Id: I40797443afe789021f3697fd779ce9f3aa3d4815
This commit is contained in:
Gregory Thiemonge 2023-04-03 04:10:35 -04:00
parent 1794a61899
commit 84a4c071ee
2 changed files with 14 additions and 8 deletions

View File

@ -582,7 +582,7 @@ class Repositories(object):
LOG.error('Quota decrement on %(clss)s called on '
'project: %(proj)s with no quota record in '
'the database.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
return
if _class == data_models.LoadBalancer:
if (quotas.in_use_load_balancer is not None and
@ -594,7 +594,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
if _class == data_models.Listener:
if (quotas.in_use_listener is not None and
quotas.in_use_listener > 0):
@ -605,7 +605,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
if _class == data_models.Pool:
if (quotas.in_use_pool is not None and
quotas.in_use_pool > 0):
@ -616,7 +616,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
if _class == data_models.HealthMonitor:
if (quotas.in_use_health_monitor is not None and
quotas.in_use_health_monitor > 0):
@ -627,7 +627,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
if _class == data_models.Member:
if (quotas.in_use_member is not None and
quotas.in_use_member > 0):
@ -638,7 +638,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
if _class == data_models.L7Policy:
if (quotas.in_use_l7policy is not None and
quotas.in_use_l7policy > 0):
@ -649,7 +649,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
if _class == data_models.L7Rule:
if (quotas.in_use_l7rule is not None and
quotas.in_use_l7rule > 0):
@ -660,7 +660,7 @@ class Repositories(object):
LOG.warning('Quota decrement on %(clss)s called on '
'project: %(proj)s that would cause a '
'negative quota.',
{'clss': type(_class), 'proj': project_id})
{'clss': _class, 'proj': project_id})
except db_exception.DBDeadlock as e:
LOG.warning('Quota project lock timed out for project: %(proj)s',
{'proj': project_id})

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed the format of log messages related to quota decrement errors. They
displayed unhelpful information, they now report the correct resource
type for which the error occurs.