Merge "quota: Remove unused `set_all_quota_usage_dirty()`"

This commit is contained in:
Zuul authored and Gerrit Code Review committed 2026-07-17 07:11:10 +00:00
commit dffba877c8
3 files changed
+4 -38

No files matched your search

-18
View File
@@ -136,24 +136,6 @@ def set_resources_quota_usage_dirty(context, resources, project_id,
return len(objs)
@db_api.retry_if_session_inactive()
@db_api.CONTEXT_WRITER
def set_all_quota_usage_dirty(context, resource, dirty=True):
"""Set the dirty bit on quota usage for all projects.
:param resource: the resource for which the dirty bit should be set
:returns: the number of projects for which the dirty bit was
actually updated
"""
# TODO(manjeets) consider squashing this method with
# set_resources_quota_usage_dirty
objs = quota_obj.QuotaUsage.get_objects(context, resource=resource)
for obj in objs:
obj.dirty = dirty
obj.update()
return len(objs)
@db_api.retry_if_session_inactive()
def create_reservation(context, project_id, deltas, expiration=None):
# This method is usually called from within another transaction.
-16
View File
@@ -161,17 +161,6 @@ class TestQuotaDbApi(testlib_api.SqlTestCaseLight):
self._verify_quota_usage(usage_info,
expected_dirty=False)
def _test_set_all_quota_usage_dirty(self, expected):
self._create_quota_usage('goals', 26)
self._create_quota_usage('goals', 12, project_id='Callejon')
self.assertEqual(expected, quota_api.set_all_quota_usage_dirty(
self.context, 'goals'))
def test_set_all_quota_usage_dirty(self):
# All goal scorers need a shower after the match, but since this is not
# admin context we can clean only one
self._test_set_all_quota_usage_dirty(expected=1)
def test_get_quota_usage_by_project(self):
self._create_quota_usage('goals', 26)
self._create_quota_usage('assists', 11)
@@ -331,8 +320,3 @@ class TestQuotaDbApiAdminContext(TestQuotaDbApi):
self.assertEqual(2, len(usage_infos))
for usage_info in usage_infos:
self.assertEqual('goals', usage_info.resource)
def test_set_all_quota_usage_dirty(self):
# All goal scorers need a shower after the match, and with admin
# context we should be able to clean all of them
self._test_set_all_quota_usage_dirty(expected=2)
+4 -4
View File
@@ -137,8 +137,8 @@ class TestTrackedResource(testlib_api.SqlTestCase):
res = self._create_resource()
self._add_data()
# explicitly set dirty flag to False
quota_api.set_all_quota_usage_dirty(
self.context, self.resource, dirty=False)
quota_api.set_resources_quota_usage_dirty(
self.context, self.resource, self.project_id, dirty=False)
# Expect correct count to be returned anyway since the first call to
# count() always resyncs with the db
self.assertEqual(2, res.count(self.context, None, self.project_id))
@@ -155,8 +155,8 @@ class TestTrackedResource(testlib_api.SqlTestCase):
res = self._create_resource()
self._add_data()
# explicitly set dirty flag to False
quota_api.set_all_quota_usage_dirty(
self.context, self.resource, dirty=False)
quota_api.set_resources_quota_usage_dirty(
self.context, self.resource, self.project_id, dirty=False)
# Expect correct count_used to be returned
# anyway since the first call to
# count_used() always resyncs with the db