From 7b7b2d5076e8449fcaa9234dafd8c27c96b2ae58 Mon Sep 17 00:00:00 2001 From: "deepika.e" Date: Mon, 3 Jun 2024 15:02:00 +0530 Subject: [PATCH] Bug 2379: Fix for RO crashes when VIM is down Added exception handling in monitor.py to ensure RO doesn't crash when a VIM is down Change-Id: I83e2b80085cfdb81d2406c19a4349214ed11035d Signed-off-by: deepika.e --- NG-RO/osm_ng_ro/monitor.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/NG-RO/osm_ng_ro/monitor.py b/NG-RO/osm_ng_ro/monitor.py index 8099eb98..93bfa11f 100644 --- a/NG-RO/osm_ng_ro/monitor.py +++ b/NG-RO/osm_ng_ro/monitor.py @@ -875,8 +875,16 @@ class MonitorVms: self.prepare_vims_to_monitor(vims_to_monitor, ro_task, target_vim) for vim in vims_to_monitor: - all_servers, all_ports = self.my_vims[vim.vim_id].get_monitoring_data() - self.update_vnfrs(all_servers, all_ports, vim.vms) + try: + all_servers, all_ports = self.my_vims[ + vim.vim_id + ].get_monitoring_data() + self.update_vnfrs(all_servers, all_ports, vim.vms) + except (DbException, MonitorDbException) as e: + raise MonitorVmsException(str(e)) + except Exception as e: + self.logger.info("Exception in vim monitoring {}".format(e)) + continue except ( DbException, MonitorDbException, @@ -891,6 +899,8 @@ class MonitorVms: raise MonitorVmsException( f"Exception while monitoring Openstack VMs: {str(e)}" ) + except Exception as e: + self.logger.info("Exception in monitoring {}".format(e)) def start_monitoring(config: dict): -- 2.25.1