← Back to team overview

yahoo-eng-team team mailing list archive

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

 

Public bug reported:

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.

** Affects: neutron
     Importance: Undecided
     Assignee: Wei Wang (damon-devops)
         Status: New

** Changed in: neutron
     Assignee: (unassigned) => Wei Wang (damon-devops)

-- 
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 OpenStack Neutron (virtual network service):
  New

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


Follow ups

References