diff --git a/Changelog.md b/Changelog.md index 06f0b391900a03aa5f75abf8a0ee03d6df4f6ebb..f37284bda1c800bbbe7f6877414fb96cd4440716 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [0.122] - 2024-06-20 +- Remove use of functools caching for /msr/services endpoint and reuse fresh data instead + ## [0.121] - 2024-06-17 - DBOARD3-956: Include all Related Services contact info in TTS notification diff --git a/inventory_provider/routes/msr.py b/inventory_provider/routes/msr.py index fe83817d5d400d59834c7ec919618c213c965539..b65692acea4d28f4797327ccc28d4a0c0704fc8f 100644 --- a/inventory_provider/routes/msr.py +++ b/inventory_provider/routes/msr.py @@ -944,8 +944,6 @@ def get_peering_services(): return Response(response, mimetype="application/json") -# TODO: @functools.cache is only available in py3.9 -@functools.lru_cache(maxsize=None) def _load_all_interfaces(): """ loads all ip interfaces in the network and returns as a dict @@ -972,8 +970,6 @@ def _load_all_interfaces(): return result -# TODO: @functools.cache is only available in py3.9 -@functools.lru_cache(maxsize=None) def _load_redundant_access_peers(): """ load all peers that should be considered @@ -997,7 +993,7 @@ def _load_redundant_access_peers(): return result -def _ip_endpoint_extractor(endpoint_details: dict): +def _ip_endpoint_extractor(all_interfaces: Dict, endpoint_details: Dict): """ special-purpose method used only by _endpoint_extractor @@ -1019,7 +1015,6 @@ def _ip_endpoint_extractor(endpoint_details: dict): 'interface': interface, } - all_interfaces = _load_all_interfaces() # sanity: should have already been checked assert hostname in all_interfaces @@ -1039,7 +1034,7 @@ def _ip_endpoint_extractor(endpoint_details: dict): return ip_endpoint -def _endpoint_extractor(endpoint_details: Dict): +def _endpoint_extractor(all_interfaces: Dict, endpoint_details: Dict): """ special-purpose method used only by get_system_correlation_services @@ -1057,9 +1052,9 @@ def _endpoint_extractor(endpoint_details: Dict): return potential_hostname = ims_equipment_to_hostname( endpoint_details['equipment']) - all_routers = _load_all_interfaces().keys() + all_routers = all_interfaces.keys() if potential_hostname in all_routers: - return _ip_endpoint_extractor(endpoint_details) + return _ip_endpoint_extractor(all_interfaces, endpoint_details) else: return { 'equipment': endpoint_details['equipment'], @@ -1107,6 +1102,8 @@ def get_system_correlation_services(): response = _ignore_cache_or_retrieve(request, cache_key, r) if not response: + all_interfaces = _load_all_interfaces() + sid_services = json.loads(r.get('ims:sid_services').decode('utf-8')) response = [] @@ -1123,7 +1120,7 @@ def get_system_correlation_services(): service_info['service_type'] = d['service_type'] service_info['customer'] = d['customer'] - endpoint = _endpoint_extractor(d) + endpoint = _endpoint_extractor(all_interfaces, d) if endpoint: service_info['endpoints'].append(endpoint) diff --git a/setup.py b/setup.py index 06743d87ca4e1857e235e8ec7dd2cfa3cb865cc6..b4def23b5ce9b5d5858592c7a7cd7adda23df80a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.121", + version="0.122", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider',