From eacb716a3aa21c2bb46ffeda9471428f9833fc4d Mon Sep 17 00:00:00 2001 From: palsus Date: Wed, 20 Jan 2021 16:47:59 +0000 Subject: [PATCH] Fix for Bug 1397: handled exception TypeError Change-Id: I8579bb681c77cc279e965ddb9c098f67982622f0 Signed-off-by: garciadeblas --- osm_mon/collector/vnf_collectors/openstack.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) -- 2.25.1