Neutron server was not compatible with member actions

Bug #1606455 reported by changzhi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
zhang ping

Bug Description

====== Problem Description =======

  Register a new extension into Neutron server, and this extension contains a member action. Just like this:

    @classmethod
    def get_resources(cls):
        """Returns rate limit resources. """
        plural_mappings = resource_helper.build_plural_mappings(
            {}, EXTENDED_ATTRIBUTES_2_0)
        attr.PLURALS.update(plural_mappings)
        action_map = {'floatingip': {
            'update_floatingip_ratelimit': 'PUT'}
        }
        return resource_helper.build_resource_info(plural_mappings,
                                                   EXTENDED_ATTRIBUTES_2_0,
                                                   constants.L3_ROUTER_NAT,
                                                   action_map=action_map)

  Adding a new member action named "update_floatingip_ratelimit". Exception will happen by calling this method by a non admin user.

  Exception reports:

    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/api/v2/resource.py", line 83, in resource
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource result = method(request=request, **args)
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo_db/api.py", line 146, in wrapper
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource ectxt.value = e.inner_exc
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 195, in __exit__
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo_db/api.py", line 136, in wrapper
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource return f(*args, **kwargs)
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/api/v2/base.py", line 216, in _handle_action
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource pluralized=self._collection)
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/policy.py", line 399, in enforce
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource pluralized)
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/policy.py", line 324, in _prepare_check
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource match_rule = _build_match_rule(action, target, pluralized)
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/policy.py", line 168, in _build_match_rule
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource target, action):
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/neutron/policy.py", line 95, in _is_attribute_explicitly_set
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource return (attribute_name in target[const.ATTRIBUTES_TO_UPDATE] and
    2016-07-26 10:07:28.813 7562 ERROR neutron.api.v2.resource KeyError: 'attributes_to_update'

Because new member action contains the "update" string. As a result, Neutron server check the target whether contains "ATTRIBUTES_TO_UPDATE". Because this is a member action so that neutron server will not go "_update" method normally. It will go "_handle_action" method. So the exception happens.

====== How to fix ======
>>> if 'update' in action:
change into
>>> if 'update' in action and target.get(const.ATTRIBUTES_TO_UPDATE):

By doing such change, will solve this problem.

tags: added: api
lilintan (lilintan)
Changed in neutron:
assignee: nobody → lilintan (lilintan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: New → In Progress
Changed in neutron:
assignee: lilintan (lilintan) → zhang ping (zp860905)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/372108
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=daa8e1b1b0c2ec5353b20aae155cea668c637ffc
Submitter: Jenkins
Branch: master

commit daa8e1b1b0c2ec5353b20aae155cea668c637ffc
Author: lilintan <email address hidden>
Date: Wed Sep 28 14:12:38 2016 +0800

    Neutron server was not compatible with member actions

    Register a new extension into Neutron server, and this extension
    contains a member action. if new member action contains the "update"
    string. As a result, Neutron server check the target whether contains
    "ATTRIBUTES_TO_UPDATE". Because this is a member action so that neutron
    server will not go "_update" method normally but "_handle_action"
    method. So the exception happens KeyError: 'attributes_to_update'.

    Co-Authored-By: zhang ping<email address hidden>
    Change-Id: Ie8bb7b9af42a82aada28d2bcdfd5b0e573ad9778
    Closes-Bug: #1606455

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 11.0.0.0b2

This issue was fixed in the openstack/neutron 11.0.0.0b2 development milestone.

tags: added: neutron-proactive-backport-potential
tags: added: neutron-easy-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/475288

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/ocata)

Reviewed: https://review.openstack.org/475288
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=83938e7cf8beb479d5e90f4bbc09d5b58ed5a4ba
Submitter: Jenkins
Branch: stable/ocata

commit 83938e7cf8beb479d5e90f4bbc09d5b58ed5a4ba
Author: lilintan <email address hidden>
Date: Wed Sep 28 14:12:38 2016 +0800

    Neutron server was not compatible with member actions

    Register a new extension into Neutron server, and this extension
    contains a member action. if new member action contains the "update"
    string. As a result, Neutron server check the target whether contains
    "ATTRIBUTES_TO_UPDATE". Because this is a member action so that neutron
    server will not go "_update" method normally but "_handle_action"
    method. So the exception happens KeyError: 'attributes_to_update'.

    Co-Authored-By: zhang ping<email address hidden>
    Change-Id: Ie8bb7b9af42a82aada28d2bcdfd5b0e573ad9778
    Closes-Bug: #1606455
    (cherry picked from commit daa8e1b1b0c2ec5353b20aae155cea668c637ffc)

tags: added: in-stable-ocata
tags: removed: neutron-easy-proactive-backport-potential neutron-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 10.0.3

This issue was fixed in the openstack/neutron 10.0.3 release.

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.