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
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)