From: palsus Date: Wed, 20 Jan 2021 16:47:59 +0000 (+0000) Subject: Fix for Bug 1397: handled exception TypeError X-Git-Tag: v9.1.0~16 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F10208%2F2;p=osm%2FMON.git Fix for Bug 1397: handled exception TypeError Change-Id: I8579bb681c77cc279e965ddb9c098f67982622f0 Signed-off-by: garciadeblas --- diff --git a/osm_mon/collector/vnf_collectors/openstack.py b/osm_mon/collector/vnf_collectors/openstack.py index 2738d5c..6c6bb58 100644 --- a/osm_mon/collector/vnf_collectors/openstack.py +++ b/osm_mon/collector/vnf_collectors/openstack.py @@ -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)