Fix for Bug 1397: handled exception TypeError 02/10202/4
authorpalsus <subhankar.pal@aricent.com>
Wed, 20 Jan 2021 16:47:59 +0000 (16:47 +0000)
committerpalsus <subhankar.pal@aricent.com>
Wed, 20 Jan 2021 17:47:30 +0000 (17:47 +0000)
Change-Id: I8579bb681c77cc279e965ddb9c098f67982622f0
Signed-off-by: palsus <subhankar.pal@aricent.com>
osm_mon/collector/vnf_collectors/openstack.py

index 2738d5c..6c6bb58 100644 (file)
@@ -201,7 +201,8 @@ class GnocchiBackend(OpenstackBackend):
                         total_measure = 0.0
                     total_measure += measures[-1][2]
 
-            except gnocchiclient.exceptions.NotFound as e:
+            except (gnocchiclient.exceptions.NotFound, TypeError) as e:
+                # Gnocchi in some Openstack versions raise TypeError instead of NotFound
                 log.debug("No metric %s found for interface %s: %s", openstack_metric_name,
                           interface['id'], e)
         return total_measure
@@ -218,12 +219,13 @@ class GnocchiBackend(OpenstackBackend):
                                                            resource_id=resource_id)
                 if measures:
                     value = measures[-1][2]
-            except gnocchiclient.exceptions.NotFound as e:
+            except (gnocchiclient.exceptions.NotFound, TypeError) as e:
                 # CPU metric in previous Openstack versions do not support rate:mean aggregation method
+                # Gnocchi in some Openstack versions raise TypeError instead of NotFound
                 if openstack_metric_name == "cpu":
                     log.debug("No metric %s found for instance %s: %s", openstack_metric_name, resource_id, e)
-                    log.debug("Retrying to get metric %s for instance %s without aggregation",
-                              openstack_metric_name, resource_id)
+                    log.info("Retrying to get metric %s for instance %s without aggregation",
+                             openstack_metric_name, resource_id)
                     measures = self.client.metric.get_measures(openstack_metric_name,
                                                                resource_id=resource_id,
                                                                limit=1)