rochaporto / collectd-openstack

collectd plugins for openstack
GNU General Public License v2.0
18 stars 26 forks source link

plugin failures when tenant_id is missing #4

Closed rochaporto closed 10 years ago

rochaporto commented 10 years ago

If a network or volume is attached to a tenant_id which in the meantime disappeared, the plugins crash:

openstack-neutron: failed to get stats :: u'231bf8653e7646d198a8afb2353823a5' :: Traceback (most recent call last):#012 File "/usr/lib/collectd/plugins/openstack/base.py", line 107, in read_callback#012 stats = self.get_stats()#012 File "/usr/lib/collec td/plugins/openstack/neutron_plugin.py", line 70, in get_stats#012 tenant = tenants[network['tenant_id']]#012KeyError: u'231bf8653e7646d198a8afb2353823a5' Jul 17 10:25:43 cat-wgtn-mon0 collectd[21553]: openstack-neutron: failed to get stats :: u'231bf8653e7646d198a8afb2353823a5' :: Traceback (most recent call last) :#012 File "/usr/lib/collectd/plugins/openstack/base.py", line 107, in read_callback#012 stats = self.get_stats()#012 File "/usr/lib/collectd/plugins/openst ack/neutron_plugin.py", line 70, in get_stats#012 tenant = tenants[network['tenant_id']]#012KeyError: u'231bf8653e7646d198a8afb2353823a5' 2014-07-17T10:25:43.854469+12:00 cat-wgtn-mon0 collectd[21553]: Unhandled python exception in read callback: UnboundLocalError: local variable 'stats' referenced before assignment Jul 17 10:25:43 cat-wgtn-mon0 collectd[21553]: Unhandled python exception in read callback: UnboundLocalError: local variable 'stats' referenced before assignment 2014-07-17T10:25:43.862936+12:00 cat-wgtn-mon0 collectd[21553]: read-function of plugin `python.openstack.neutron_plugin' failed. Will suspend it for 640.000 seconds.

This situation can happen when there are some inconsistencies in the dbs, and we should protect against it.