mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-04-26 00:06:26 +00:00
Fix resource cache not being used (#228)
Fix resource cache not being used SUMMARY This was some bad copy/paste from the openshift client. The resource cache was never being used resulting in unnecessary HTTP requests. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: None <None> Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net> Reviewed-by: None <None>
This commit is contained in:
3
changelogs/fragments/228-fix-resource-cache.yml
Normal file
3
changelogs/fragments/228-fix-resource-cache.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
bugfixes:
|
||||
- fix resource cache not being used (https://github.com/ansible-collections/kubernetes.core/pull/228).
|
||||
@@ -18,6 +18,7 @@ import os
|
||||
from collections import defaultdict
|
||||
import hashlib
|
||||
import tempfile
|
||||
from functools import partial
|
||||
|
||||
import kubernetes.dynamic
|
||||
import kubernetes.dynamic.discovery
|
||||
@@ -74,7 +75,7 @@ class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
||||
else:
|
||||
try:
|
||||
with open(self.__cache_file, 'r') as f:
|
||||
self._cache = json.load(f, cls=CacheDecoder(self.client))
|
||||
self._cache = json.load(f, cls=partial(CacheDecoder, self.client))
|
||||
if self._cache.get('library_version') != __version__:
|
||||
# Version mismatch, need to refresh cache
|
||||
self.invalidate_cache()
|
||||
|
||||
Reference in New Issue
Block a user