← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1724043] Re: l3-agent network_update() can throw an excetion if router ex_gw_port is None

 

Reviewed:  https://review.openstack.org/512382
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=2cea213d94e3ac7675d62491cec6c85253285b92
Submitter: Zuul
Branch:    master

commit 2cea213d94e3ac7675d62491cec6c85253285b92
Author: Brian Haley <bhaley@xxxxxxxxxx>
Date:   Mon Oct 16 14:35:25 2017 -0400

    Do not try and iterate [None] in l3-agent network_update()
    
    Since ri.ex_gw_port can be None, the l3-agent can throw an
    exception when looking for ports it might have in a given
    network.
    
    Change-Id: I3ab3e9c012022cd7eefa5c609ca9540649079ad3
    Closes-bug: #1724043


** Changed in: neutron
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1724043

Title:
  l3-agent network_update() can throw an excetion if router ex_gw_port
  is None

Status in neutron:
  Fix Released

Bug description:
  I've seen this error a couple of times in downstream testing, but
  looks like it could be just as broken upstream:

  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server [req-a1152197-d8b1-4e34-ae63-8a94fd69ebcd faf66db1b6de4c56a9925b9e5aa3369d c977198dffa24e6f8e9e8c8c4cf3211c - - -] Exception during message handling: TypeError: 'NoneType' object has no attribute '__getitem__'
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server Traceback (most recent call last):
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 160, in _process_incoming
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     res = self.dispatcher.dispatch(message)
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 213, in dispatch
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     return self._do_dispatch(endpoint, method, ctxt, args)
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 183, in _do_dispatch
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     result = func(ctxt, **new_args)
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/osprofiler/profiler.py", line 153, in wrapper
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     return f(*args, **kwargs)
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/osprofiler/profiler.py", line 153, in wrapper
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     return f(*args, **kwargs)
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/neutron/agent/l3/agent.py", line 446, in network_update
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     if any(port_belongs(p) for p in ports):
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/neutron/agent/l3/agent.py", line 446, in <genexpr>
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     if any(port_belongs(p) for p in ports):
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/neutron/agent/l3/agent.py", line 445, in <lambda>
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server     port_belongs = lambda p: p['network_id'] == network_id
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server TypeError: 'NoneType' object has no attribute '__getitem__'
  2017-10-09 18:36:29.507 126916 ERROR oslo_messaging.rpc.server

  Since ri.ex_gw_port can be None, that can cause an exception when
  looking for ports we might have in that network.  Here's an example if
  the port is None:

    ports = itertools.chain(ri.internal_ports, [ri.ex_gw_port])

  >>> import itertools
  >>> foo = itertools.chain([], [None])
  >>> port_belongs = lambda p: p['network_id'] == network_id
  >>> any(port_belongs(p) for p in foo)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "<stdin>", line 1, in <genexpr>
    File "<stdin>", line 1, in <lambda>
  TypeError: 'NoneType' object has no attribute '__getitem__'

  We need to check if it's None and use [] instead.

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1724043/+subscriptions


References