diff --git a/Changelog.md b/Changelog.md index 8fe43d9a2135906a53c36474c210b328d567d566..f6068b1586bff9209f952ce406a8ed760d05299c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [0.71] - 2021-08-20 +- DBOARD3-433: fix missing classification data during Inventory refresh + ## [0.70] - 2021-08-20 - DBOARD3-459: fix performance issue with /poller/interfaces - POL1-483: add dashboard mappings to /poller/interfaces response diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index e0e9bc2cf422562831d349b553d984150dd90970..79b3ebd098cbced64efe2a48261a4e89a3d2c2be 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -443,6 +443,7 @@ def reload_router_config(self, hostname): self.log_info(f'updated configuration for {hostname}') +# updated with transaction def _erase_next_db(config): """ flush next db, but first save latch and then restore afterwards @@ -453,8 +454,23 @@ def _erase_next_db(config): """ r = get_next_redis(config) saved_latch = get_latch(r) - r.flushdb() + if saved_latch: + # execute as transaction to ensure that latch is always available in + # db that is being flushed + rp = r.pipeline() + rp.multi() + rp.flushdb() + set_single_latch( + rp, + saved_latch['this'], + saved_latch['current'], + saved_latch['next'], + saved_latch.get('timestamp', 0) + ) + rp.execute() + + # ensure latch is consistent in all dbs set_latch( config, new_current=saved_latch['current'], @@ -1167,7 +1183,7 @@ def update_entry_point(self): ) lab_routers = InventoryTask.config.get('lab-routers', []) - _erase_next_db_chorded(InventoryTask.config) + _erase_next_db(InventoryTask.config) update_latch_status(InventoryTask.config, pending=True) tasks = chord( @@ -1238,41 +1254,6 @@ def retrieve_and_persist_neteng_managed_device_list( return netdash_equipment -# updated with transaction -def _erase_next_db_chorded(config): - """ - flush next db, but first save latch and then restore afterwards - - TODO: handle the no latch scenario nicely - :param config: - :return: - """ - r = get_next_redis(config) - saved_latch = get_latch(r) - - if saved_latch: - # execute as transaction to ensure that latch is always available in - # db that is being flushed - rp = r.pipeline() - rp.multi() - rp.flushdb() - set_single_latch( - rp, - saved_latch['this'], - saved_latch['current'], - saved_latch['next'], - saved_latch.get('timestamp', 0) - ) - rp.execute() - - # ensure latch is consistent in all dbs - set_latch( - config, - new_current=saved_latch['current'], - new_next=saved_latch['next'], - timestamp=saved_latch.get('timestamp', 0)) - - # updated @app.task(base=InventoryTask, bind=True, name='reload_lab_router_config') @log_task_entry_and_exit @@ -1837,7 +1818,7 @@ def final_task(self): def populate_poller_interfaces_cache(warning_callback=lambda s: None): - no_lab_cache_key = 'classifier-cache:poller-interfaces:no-lab' + no_lab_cache_key = 'classifier-cache:poller-interfaces:all:no-lab' all_cache_key = 'classifier-cache:poller-interfaces:all' non_lab_populated_interfaces = None all_populated_interfaces = None diff --git a/setup.py b/setup.py index 4e84bda1964e518d5f898d628bc89de2b343cf79..80508370e17df848897ee1dc426ebac7f50c4621 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.70", + version="0.71", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider', diff --git a/test/test_worker.py b/test/test_worker.py index fa254f671fce9d5e1b96109b839ce26dd9aa2ed2..7d6d59d86b8ba2c7a5f465e55ed1965f9fc41810 100644 --- a/test/test_worker.py +++ b/test/test_worker.py @@ -499,9 +499,10 @@ def test_populate_poller_interfaces_cache( return_value=r) populate_poller_interfaces_cache() - assert r.exists("classifier-cache:poller-interfaces:no-lab") + assert r.exists("classifier-cache:poller-interfaces:all:no-lab") assert r.exists("classifier-cache:poller-interfaces:all") - no_lab = r.get("classifier-cache:poller-interfaces:no-lab").decode("utf-8") + no_lab = \ + r.get("classifier-cache:poller-interfaces:all:no-lab").decode("utf-8") all = r.get("classifier-cache:poller-interfaces:all").decode("utf-8") assert json.loads(no_lab) == no_lab_res all_res = no_lab_res + lab_res