mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-21 20:59:10 +00:00
Merge 071c402ee1 into bc22fbcaa0
This commit is contained in:
commit
e190cd0663
2 changed files with 13 additions and 1 deletions
2
changelogs/fragments/11365-pickle-cache-miss.yml
Normal file
2
changelogs/fragments/11365-pickle-cache-miss.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- nmap with pickle as cache plugin - Fixed the cache misses due to the absence of the Plugin Interposer (Issue https://github.com/ansible-collections/community.general/issues/11365)
|
||||
|
|
@ -175,6 +175,16 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
|
||||
return valid
|
||||
|
||||
def _is_plugin_interposer(self):
|
||||
return self._cache._plugin._persistent
|
||||
|
||||
def _get_value_from_cache(self, cache_key):
|
||||
if not self._is_plugin_interposer():
|
||||
self._cache[cache_key] = self._cache._plugin.get(cache_key)
|
||||
self._cache._retrieved = self._cache
|
||||
|
||||
return self._cache[cache_key]
|
||||
|
||||
def parse(self, inventory, loader, path, cache=True):
|
||||
try:
|
||||
self._nmap = get_bin_path("nmap")
|
||||
|
|
@ -198,7 +208,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
|
||||
if attempt_to_read_cache:
|
||||
try:
|
||||
results = self._cache[cache_key]
|
||||
results = self._get_value_from_cache(cache_key)
|
||||
except KeyError:
|
||||
# This occurs if the cache_key is not in the cache or if the cache_key expired, so the cache needs to be updated
|
||||
cache_needs_update = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue