← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1337787] Re: Port update crashes when device id does not need to be updated

 

** Changed in: neutron
       Status: Fix Committed => 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/1337787

Title:
  Port update crashes when device id does not need to be updated

Status in OpenStack Neutron (virtual network service):
  Fix Released

Bug description:
  When I call the update_port() method using the ML2 plugin, I see the following error:
  2014-07-04 10:05:40.043 17585 ERROR neutron.api.v2.resource [-] add_router_interface failed
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource Traceback (most recent call last):
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource   File "/usr/lib/python2.6/site-packages/neutron/api/v2/resource.py", line 84, in resource
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource     result = method(request=request, **args)
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource   File "/usr/lib/python2.6/site-packages/neutron/api/v2/base.py", line 185, in _handle_action
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource     return getattr(self._plugin, name)(*arg_list, **kwargs)
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource   File "/usr/lib/python2.6/site-packages/neutron/services/pn_services/router.py", line 224, in add_router_interface
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource     self.update_port(context, p['id'], port_info)
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource   File "/usr/lib/python2.6/site-packages/neutron/services/pn_services/router.py", line 349, in update_port
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource     """
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource   File "/usr/lib/python2.6/site-packages/neutron/db/db_base_plugin_v2.py", line 1397, in update_port
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource     and (changed_device_id or changed_device_owner)):
  2014-07-04 10:05:40.043 17585 TRACE neutron.api.v2.resource UnboundLocalError: local variable 'changed_device_id' referenced before assignment

  On further inspection of the file in question (/usr/lib/python2.6
  /site-packages/neutron/db/db_base_plugin_v2.py: update_port()), I see
  that the variable 'changed_device_id' is only declared within an 'if'
  condition, and not otherwise. This causes the crash as a later 'if'
  tries to read from it but finds it not declared.

  --snip--
      def update_port(self, context, id, port):
          p = port['port']

          changed_ips = False
          with context.session.begin(subtransactions=True):
              port = self._get_port(context, id)
              if 'device_owner' in p:
                  current_device_owner = p['device_owner']
                  changed_device_owner = True 
              else:
                  current_device_owner = port['device_owner']
                  changed_device_owner = False
              if p.get('device_id') != port['device_id']:
                  changed_device_id = True 

              # if the current device_owner is ROUTER_INF and the device_id or
              # device_owner changed check device_id is not another tenants
              # router
              if ((current_device_owner == constants.DEVICE_OWNER_ROUTER_INTF)
                      and (changed_device_id or changed_device_owner)):
                  self._enforce_device_owner_not_router_intf_or_device_id(
                      context, p, port['tenant_id'], port)
  --snip-- 

  'changed_device_id' should be set to 'False' by default.

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


References