From 0e7767c6a69da6c51303931ce8d058e8cffdf7aa Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 4 May 2016 14:00:15 -0400 Subject: [PATCH] Fix fact gathering module being absent Somewhere recently we broke the ability to gather multiple modules in one scan job pass. This fixes that, it also further improves the scan job performance. --- awx/plugins/fact_caching/tower.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/awx/plugins/fact_caching/tower.py b/awx/plugins/fact_caching/tower.py index 2229b53375..42bf6be70b 100755 --- a/awx/plugins/fact_caching/tower.py +++ b/awx/plugins/fact_caching/tower.py @@ -50,7 +50,7 @@ class CacheModule(BaseCacheModule): def __init__(self, *args, **kwargs): # Basic in-memory caching for typical runs self._cache = {} - self._cache_prev = {} + self._all_keys = {} # This is the local tower zmq connection self._tower_connection = C.CACHE_PLUGIN_CONNECTION @@ -72,12 +72,10 @@ class CacheModule(BaseCacheModule): def identify_new_module(self, key, value): # Return the first key found that doesn't exist in the # previous set of facts - if key in self._cache_prev: - value_old = self._cache_prev[key] - for k,v in value.iteritems(): - if k not in value_old: - if not k.startswith('ansible_'): - return k + if key in self._all_keys: + for k in value.iterkeys(): + if k not in self._all_keys[key] and not k.startswith('ansible_'): + return k # First time we have seen facts from this host # it's either ansible facts or a module facts (including module_setup) elif len(value) == 1: @@ -110,7 +108,7 @@ class CacheModule(BaseCacheModule): # Assume ansible fact triggered the set if no new module found facts = self.filter_ansible_facts(value) if not module else dict({ module : value[module]}) self._cache[key] = value - self._cache_prev = copy(self._cache) + self._all_keys[key] = value.keys() packet = { 'host': key, 'inventory_id': os.environ['INVENTORY_ID'],