FloatingIPollster resource_metadata attrbute match porblems

Bug #1173845 reported by Liang Junxue
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Undecided
Feilong Wang

Bug Description

when run the ceilometer-agent-central, the error log shows as following:

2013-04-28 14:30:11 ERROR [ceilometer.central.manager] address
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ceilometer-2013.2.a50.g7dfd846-py2.7.egg/ceilometer/central/manager.py", line 50, in poll_and_publish
    self.manager)))
  File "/usr/local/lib/python2.7/dist-packages/ceilometer-2013.2.a50.g7dfd846-py2.7.egg/ceilometer/network/floatingip.py", line 56, in get_counters
    'address': ip.address,
  File "/usr/lib/python2.7/dist-packages/novaclient/base.py", line 335, in __getattr__
    raise AttributeError(k)
AttributeError: address

fix it by change the file: /ceilometer/network/floatingip.py

class FloatingIPPollster(plugin.CentralPollster):

    LOG = log.getLogger(__name__ + '.floatingip')

    @staticmethod
    def get_counter_names():
        return ['ip.floating']

    def get_counters(self, manager):
        nv = nova_client.Client()
        # import pdb
        # pdb.set_trace()
        for ip in nv.floating_ip_get_all():
            # self.LOG.info("FLOATING IP USAGE: %s" % ip.address)
            self.LOG.info("FLOATING IP USAGE: %s" % ip.ip)
            #import pdb
            #db.set_trace()
            yield counter.Counter(
                name='ip.floating',
                type=counter.TYPE_GAUGE,
                unit='ip',
                volume=1,
                user_id=None,
                # project_id=ip.project_id,
                project_id=ip.id,
                resource_id=ip.id,
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata={
                    # 'address': ip.address,
                    'address': ip.ip,
                    # 'fixed_ip_id': ip.fixed_ip_id,
                    'fixed_ip_id': ip.fixed_ip,
                    # 'host': ip.host,
                    'host': ip.instance_id,
                    # 'pool': ip.pool,
                    'pool': ip.pool
                    # 'auto_assigned': ip.auto_assigned
                })

Liang Junxue (liangjx)
information type: Private Security → Public
tags: added: ceilometer floating ip
Revision history for this message
Liang Junxue (liangjx) wrote :

# resource_id=ip.id,
resource_id=ip.instance_id,

Feilong Wang (flwang)
Changed in ceilometer:
assignee: nobody → Fei Long Wang (flwang)
Revision history for this message
Feilong Wang (flwang) wrote :

I can recreate the problem. And after investigation, there are 3 places need to be fixed.

1. Update the ip.address with ip.ip to fix the current apparent issue. But actually, the result format method existed since essex, so I don't understand why the #1 and #2 issues existed, see here: https://github.com/openstack/nova/blob/stable/essex/nova/api/openstack/compute/contrib/floating_ips.py#L64

2. Fix method https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/contrib/floating_ips.py#L62, return more attributes of floating ip for Ceilometer, such as project_id, auto_assigned, etc. This will be fixed in Nova. so I will open a bug in Nova to track the change.

3. Add more test cases for test_floatingip.py to fix the test gaps

---------------------------------------------------------------------------------------------
2013-04-29 22:23:58 ERROR [ceilometer.central.manager] address
Traceback (most recent call last):
  File "/home/flwang/MyWorkSpace/workspace_community/ceilometer/ceilometer/central/manager.py", line 50, in poll_and_publish
    self.manager)))
  File "/home/flwang/MyWorkSpace/workspace_community/ceilometer/ceilometer/network/floatingip.py", line 43, in get_counters
    self.LOG.info("FLOATING IP USAGE: %s" % ip.address)
  File "/opt/stack/python-novaclient/novaclient/base.py", line 332, in __getattr__
    raise AttributeError(k)
AttributeError: address

Changed in ceilometer:
status: New → Confirmed
status: Confirmed → In Progress
Revision history for this message
Feilong Wang (flwang) wrote :

Based on the discussion with eglynn and jd__, the bug will be fixed in tow passes. For the fix of this bug, I will try to fix current apparent issue by using the attributes Nova gives. And I think the fix can be patch for Grizzly.

Besides, I may open another bug to leverage the attributes after fixing the bug of Nova (https://bugs.launchpad.net/nova/+bug/1174802)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

Fix proposed to branch: master
Review: https://review.openstack.org/27975

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/27975
Committed: http://github.com/openstack/ceilometer/commit/39d9ca7b330e15eed5200bad4943818c353332ed
Submitter: Jenkins
Branch: master

commit 39d9ca7b330e15eed5200bad4943818c353332ed
Author: Fei Long Wang <email address hidden>
Date: Wed May 1 16:14:06 2013 -0500

    Fixes AttributeError of FloatingIPPollster

    Currently FloatingIPPollster is using Nova client to get floating
    IP metrics instead of accessing OpenStack DB directly. So there are
    some attributes can't be accessed from Nova /os-floating-ips REST API.
    In this fix, those attributes usage will be removed temporarily.
    And they will be back after fix the Nova bug 1174802.

    Fixes bug 1173845

    Change-Id: I61572c50db6f90c26bbdb7da5f0e9a249b405e58

Changed in ceilometer:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: none → havana-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: havana-1 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.