← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1443342] Re: The assignment in extensions.py may cause resources point to same object

 

Thanks for the patch. I see the issue now.

The current unit test doesn't even reproduce the actual bug. It just
asserts something that leads to the bug. I'm going to propose a patch to
make the unit test reproduce the actual issue as I understand it. I'll
add you as a reviewer to confirm that I understood it correctly.

** Changed in: neutron
       Status: Incomplete => 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/1443342

Title:
  The assignment in extensions.py may cause resources point to same
  object

Status in neutron:
  Fix Released

Bug description:
  In neutron.api.extension.ExtensionManager.extend_resources, line 481
  of api/extension.py, we got this:

                  try:
                      extended_attrs = ext.get_extended_resources(version)
                      for resource, resource_attrs in extended_attrs.iteritems():
                          if attr_map.get(resource, None):
                              attr_map[resource].update(resource_attrs)
                          else:
                              ### Attention here ###
                              attr_map[resource] = resource_attrs
                              ######
                  except AttributeError:
                      LOG.exception(_LE("Error fetching extended attributes for "
                                        "extension '%s'"), ext.get_name())

  This is scenario:

  When a extension's resource map is generated other than write by hand,
  like this:

  
  EXTENDED_TIMESTAMP = {
      'created_at': {'allow_post': False, 'allow_put': False,
                     'is_visible': True},
  }
  EXTENDED_RESOURCES = ['floatingips', 'routers', 'networks', 'ports',
                        'subnets', 'security_groups']

      def get_extended_resources(self, version):
          attrs = {}
          if version == "2.0":
              for resources in EXTENDED_RESOURCES:
                  attrs[resources] = EXTENDED_TIMESTAMP
          return attrs

  
  So this function `get_entened_resources` will return a dict which each item is the same object.
  And then, for our extension's load sequence is random, this extension maybe load first, so it will run "attr_map[resource]".

  It leads to all these resources' attr_map point to same object, once
  one of them updated, others will be affacted.

  The solution is pretty easy, just use method copy from package copy is
  solve this.

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


References