From b898e701c87ae68bc6d0ea0769af0fba5fda54db Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Thu, 4 Jun 2020 14:54:42 +0200
Subject: [PATCH] allow joblog cached response to be ignored when searching

---
 inventory_provider/tasks/monitor.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/inventory_provider/tasks/monitor.py b/inventory_provider/tasks/monitor.py
index d12bd5c4..b976caba 100644
--- a/inventory_provider/tasks/monitor.py
+++ b/inventory_provider/tasks/monitor.py
@@ -164,7 +164,7 @@ def _redis_client_proc(key_queue, value_queue, config_params):
         value_queue.put(None)
 
 
-def load_task_log(config_params):
+def load_task_log(config_params, ignored_keys=[]):
     """
     load the task log in a formatted dictionary:
       keys are task uuid's
@@ -176,6 +176,7 @@ def load_task_log(config_params):
     the redis master the cumulative latency causes nginx/gunicorn timeouts
 
     :param config_params: app config
+    :param ignored_keys: list of keys to ignore if found
     :return:
     """
     response_queue = queue.Queue()
@@ -191,8 +192,13 @@ def load_task_log(config_params):
 
     r = get_current_redis(config_params)
     for k in r.scan_iter('joblog:*'):
+        k = k.decode('utf-8')
+        if k in ignored_keys:
+            logger.debug('ignoring key: {k}')
+            continue
+
         t = random.choice(threads)
-        t['queue'].put(k.decode('utf-8'))
+        t['queue'].put(k)
 
     # tell all threads there are no more keys coming
     for t in threads:
-- 
GitLab