Skip to content

Commit

Permalink
Fix resource cache not being used (#228)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: None <None>
  • Loading branch information
gravesm authored Sep 9, 2021
1 parent 8bb455a commit b397439
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/228-fix-resource-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- fix resource cache not being used (https://github.com/ansible-collections/kubernetes.core/pull/228).
3 changes: 2 additions & 1 deletion plugins/module_utils/client/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from collections import defaultdict
import hashlib
import tempfile
from functools import partial

import kubernetes.dynamic
import kubernetes.dynamic.discovery
Expand Down Expand Up @@ -74,7 +75,7 @@ def __init_cache(self, refresh=False):
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()
Expand Down

0 comments on commit b397439

Please sign in to comment.