diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index bcf6d4f659c06dda84c6bad637e7c78196b166c6..e92980b6206db1d1233d3e5c4c4c5e2cf2ce684b 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -1886,18 +1886,18 @@ def populate_error_report_interfaces_cache(warning_callback=lambda s: None): if not all_populated_interfaces: previous_r = get_current_redis(InventoryTask.config) - def _load_previous(key): - try: - warning_callback(f"populating {key} " - "from previously cached data") - return json.loads(previous_r.get(key)) - except Exception as e: - warning_callback(f"Failed to load {key} " - f"from previously cached data: {e}") + try: + warning_callback(f"populating {all_cache_key} from previously cached data") + previous = json.loads(previous_r.get(all_cache_key)) + all_populated_interfaces = sorted( + previous, key=lambda i: (i["router"], i["name"]) + ) + except Exception as e: + warning_callback( + f"Failed to load {all_cache_key} from previously cached data: {e}" + ) + return - all_populated_interfaces = sorted( - _load_previous(all_cache_key), key=lambda i: (i["router"], i["name"]) - ) router_interfaces = {} for ifc in all_populated_interfaces: diff --git a/test/conftest.py b/test/conftest.py index d726efd182098405f58588dc1b56ef910244d9b2..c77fc91d9877f8d274bbbf1987d2a64a5430dbfc 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -259,7 +259,7 @@ def client(flask_config_filename, data_config_filename, mocked_redis): os.environ['FLASK_SETTINGS_FILENAME'] = flask_config_filename os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'] = data_config_filename app = inventory_provider.create_app(setup_logging=False) - app.testing = True + app.testing = True # Show exceptions instead of generid 500 status with app.test_client() as c: yield c