diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index ff507dda2bee5d7578cb25cdfceb4d1ac2b90b5c..054bc5ab0dc5c931bba4b1fcee4fccc716a805e1 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -446,7 +446,7 @@ def launch_refresh_cache_all(config): """ logger = logging.getLogger(__name__) - r = get_next_redis(InventoryTask.config) + r = get_next_redis(config) r.flushdb() # first batch of subtasks: refresh cached opsdb data @@ -466,13 +466,15 @@ def launch_refresh_cache_all(config): ] # for hostname in _derive_router_hostnames(config): hostnames = _derive_router_hostnames(config) - for hostname in hostnames[0:2]: - logger.debug('queueing router refresh jobs for %r' % hostname) - subtasks.append(reload_router_config.apply_async(args=[hostname])) + hostnames = list(hostnames)[:2] + logger.error("HOSTNAMES: %r" % hostnames) + # for hostname in hostnames: + # logger.debug('queueing router refresh jobs for %r' % hostname) + # subtasks.append(reload_router_config.apply_async(args=[hostname])) pending_task_ids = [x.id for x in subtasks] - t = refresh_finalizer.apply_async(args=json.dumps(pending_task_ids)) + t = refresh_finalizer.apply_async(args=[json.dumps(pending_task_ids)]) pending_task_ids.append(t.id) return pending_task_ids @@ -481,7 +483,7 @@ def _wait_for_tasks(task_ids): logger = logging.getLogger(__name__) start_time = time.time() - while task_ids and time.time() - start_time > FINALIZER_TIMEOUT_S: + while task_ids and time.time() - start_time < FINALIZER_TIMEOUT_S: logger.debug('waiting for tasks to complete: %r', task_ids) time.sleep(FINALIZER_POLLING_FREQUENCY_S) task_ids = [ @@ -502,6 +504,7 @@ def _wait_for_tasks(task_ids): def refresh_finalizer(self, pending_task_ids_json): logger = logging.getLogger(__name__) logger.debug('>>> refresh_finalizer') + logger.debug('task_ids: %r' % pending_task_ids_json) input_schema = { "$schema": "http://json-schema.org/draft-07/schema#", @@ -510,7 +513,8 @@ def refresh_finalizer(self, pending_task_ids_json): } task_ids = json.loads(pending_task_ids_json) - assert jsonschema.validate(task_ids, input_schema) + logger.debug('task_ids: %r' % task_ids) + jsonschema.validate(task_ids, input_schema) _wait_for_tasks(task_ids) _build_subnet_db()