Bug 2379: Fix for RO crashes when VIM is down 06/14406/5
authordeepika.e <deepika.e@tataelxsi.co.in>
Mon, 3 Jun 2024 09:32:00 +0000 (15:02 +0530)
committerelumalai <deepika.e@tataelxsi.co.in>
Fri, 25 Oct 2024 06:44:25 +0000 (08:44 +0200)
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 <deepika.e@tataelxsi.co.in>
NG-RO/osm_ng_ro/monitor.py

index 8099eb9..93bfa11 100644 (file)
@@ -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):