Skip to content

Commit fd10af1

Browse files
leustjoker-at-work
authored andcommitted
Fix SAPQuotaEngine cache client initialization
The SAPQuotaEngine instance is created as a module variable (nova.quota.QUOTAS), so the CONF might have not been initialized at the point when SAPQuotaEngine.__init__ is called. Similarily to how the self._driver is initialised, we are now initializing the self._cache client outside of the constructor, making sure the CONF is also initialized at that point. This fixes the issues where DictCacheBackend was used by the SAPQuotaEngine, instead of the configured Memcached backend. Change-Id: Iceba3c7820f9c6b9255ef6e00a9f49ed4677c12f
1 parent d1a45a5 commit fd10af1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

nova/quota.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,10 +1117,17 @@ class SAPQuotaEngine(QuotaEngine):
11171117

11181118
def __init__(self, quota_driver=None, resources=None):
11191119
self._original_resources = {}
1120-
expiration_time = CONF.quota.sap_resources_cache_time
1121-
self._cache = cache.get_client(expiration_time=expiration_time)
1120+
self.__cache = None
11221121
super().__init__(resources=resources, quota_driver=quota_driver)
11231122

1123+
@property
1124+
def _cache(self):
1125+
if not self.__cache:
1126+
expiration_time = CONF.quota.sap_resources_cache_time
1127+
self.__cache = cache.get_client(
1128+
expiration_time=expiration_time)
1129+
return self.__cache
1130+
11241131
@property
11251132
def _resources(self):
11261133
resources = self._cache.get(self._CACHE_KEY)

0 commit comments

Comments
 (0)