update port receive 500

Bug #1838396 reported by ZhouHeng
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
ZhouHeng

Bug Description

This bug tracker is for errors with the documentation, use the following as a template and remove or add fields as you see fit. Convert [ ] into [x] to check boxes:

- [ ] This doc is inaccurate in this way: ______
- [ ] This is a doc addition request.
- [ ] I have a fix to the document that I can paste below including example: input and output.

If you have a troubleshooting or support issue, use the following resources:

 - Ask OpenStack: http://ask.openstack.org
 - The mailing list: http://lists.openstack.org
 - IRC: 'openstack' channel on Freenode

-----------------------------------
Release: on 2019-07-29 13:09:43
SHA: aaae83acaac5f58918ff53613b4de20bbfe30d81
Source: https://opendev.org/openstack/neutron-lib/src/api-ref/source/v2/index.rst
URL: https://docs.openstack.org/api-ref/network/v2/index.html

Revision history for this message
ZhouHeng (zhouhenglc) wrote :
Download full text (5.0 KiB)

When I use empty port body to update port, neutron server return 500

req_sess = requests.session()
req_sess.headers["X-Auth-Token"] = token
resp = req_sess.put("http://10.180.210.69:9696/v2.0/ports/d13ed771-b175-4f22-8a65-4447f72e9bcd",
 json=dict(port=dict()))

here's the neutron server error:

Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation e, statement, parameters, cursor, context
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1464, in _handle_dbapi_except
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation util.raise_from_cause(newraise, exc_info)
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 399, in raise_from_cause
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation reraise(type(exception), exception, tb=exc_tb, cause=cause)
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation cursor, statement, parameters, context
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation cursor.execute(statement, parameters)
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation result = self._query(query)
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation conn.query(q)
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 517, in query
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation self._affected_rows = self._read_query_result(unbuffered=unbuffered)
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation result.read()
Jul 30 06:44:41 nfs neutron-server[11250]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/lib/python2.7/s...

Read more...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.opendev.org/673486

Changed in neutron:
assignee: nobody → ZhouHeng (zhouhenglc)
status: New → In Progress
Revision history for this message
ZhouHeng (zhouhenglc) wrote :
tags: added: api
removed: api-ref
Changed in neutron:
importance: Undecided → Medium
Revision history for this message
Brian Haley (brian-haley) wrote :

Do you have the call trace from the neutron code? From what you linked I only see the sqlalchemy error and not where the call originated.

Revision history for this message
ZhouHeng (zhouhenglc) wrote :

the error if throw in submit to mysql. from the stack, neutron server set '{}' to vnic_type.By check the code, I found in line 430(plugins/ml2/plugin.py):
vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)

if attrs = {}, vnic_type will be assigned {}, so we can encounter this bug.
I have submitted a patch. https://review.opendev.org/#/c/673486/

Changed in neutron:
assignee: ZhouHeng (zhouhenglc) → Brin Zhang (zhangbailin)
Changed in neutron:
assignee: Brin Zhang (zhangbailin) → ZhouHeng (zhouhenglc)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.opendev.org/673486
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=dd080c70b423a56a69abf7e52d1fee0cb7988c92
Submitter: Zuul
Branch: master

commit dd080c70b423a56a69abf7e52d1fee0cb7988c92
Author: zhouhenglc <email address hidden>
Date: Tue Jul 30 19:57:18 2019 +0800

    fix update port bug

    when update port set body={"port": {}}, neutron server will return 500.

    In function _process_port_binding_attributes(plugins/ml2/plugin.py),
    when update port body={"port": {}}
    attrs={}
    vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
    vnic_type = {}
    because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE)
    vnic_type will be replicated as attrs.

    Change-Id: I40d388543387ebdd72f26d761339c1829bef9413
    Partial-bug: #1838396

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

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/674965

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

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/674966

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

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/674968

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

Fix proposed to branch: stable/pike
Review: https://review.opendev.org/674970

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.opendev.org/674971

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

Reviewed: https://review.opendev.org/674965
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=6b9bedd151eb816e03e134d99edf769b25564551
Submitter: Zuul
Branch: stable/stein

commit 6b9bedd151eb816e03e134d99edf769b25564551
Author: zhouhenglc <email address hidden>
Date: Tue Jul 30 19:57:18 2019 +0800

    fix update port bug

    when update port set body={"port": {}}, neutron server will return 500.

    In function _process_port_binding_attributes(plugins/ml2/plugin.py),
    when update port body={"port": {}}
    attrs={}
    vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
    vnic_type = {}
    because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE)
    vnic_type will be replicated as attrs.

    Change-Id: I40d388543387ebdd72f26d761339c1829bef9413
    Partial-bug: #1838396
    (cherry picked from commit dd080c70b423a56a69abf7e52d1fee0cb7988c92)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/rocky)

Reviewed: https://review.opendev.org/674966
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=b4e544fa9a1ee40fb753e9756ca50a21e8d0ea7c
Submitter: Zuul
Branch: stable/rocky

commit b4e544fa9a1ee40fb753e9756ca50a21e8d0ea7c
Author: zhouhenglc <email address hidden>
Date: Tue Jul 30 19:57:18 2019 +0800

    fix update port bug

    when update port set body={"port": {}}, neutron server will return 500.

    In function _process_port_binding_attributes(plugins/ml2/plugin.py),
    when update port body={"port": {}}
    attrs={}
    vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
    vnic_type = {}
    because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE)
    vnic_type will be replicated as attrs.

    Change-Id: I40d388543387ebdd72f26d761339c1829bef9413
    Partial-bug: #1838396
    (cherry picked from commit dd080c70b423a56a69abf7e52d1fee0cb7988c92)

tags: added: in-stable-rocky
tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/queens)

Reviewed: https://review.opendev.org/674968
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=a0ac712a3508cca9e3fb805d8bb296538cb865b1
Submitter: Zuul
Branch: stable/queens

commit a0ac712a3508cca9e3fb805d8bb296538cb865b1
Author: zhouhenglc <email address hidden>
Date: Tue Jul 30 19:57:18 2019 +0800

    fix update port bug

    when update port set body={"port": {}}, neutron server will return 500.

    In function _process_port_binding_attributes(plugins/ml2/plugin.py),
    when update port body={"port": {}}
    attrs={}
    vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
    vnic_type = {}
    because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE)
    vnic_type will be replicated as attrs.

    Change-Id: I40d388543387ebdd72f26d761339c1829bef9413
    Partial-bug: #1838396
    (cherry picked from commit dd080c70b423a56a69abf7e52d1fee0cb7988c92)

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

Reviewed: https://review.opendev.org/674970
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=fbc02ffc0664a056fe81ffac288a82bed9c960d6
Submitter: Zuul
Branch: stable/pike

commit fbc02ffc0664a056fe81ffac288a82bed9c960d6
Author: zhouhenglc <email address hidden>
Date: Tue Jul 30 19:57:18 2019 +0800

    fix update port bug

    when update port set body={"port": {}}, neutron server will return 500.

    In function _process_port_binding_attributes(plugins/ml2/plugin.py),
    when update port body={"port": {}}
    attrs={}
    vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
    vnic_type = {}
    because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE)
    vnic_type will be replicated as attrs.

    Change-Id: I40d388543387ebdd72f26d761339c1829bef9413
    Partial-bug: #1838396
    (cherry picked from commit dd080c70b423a56a69abf7e52d1fee0cb7988c92)

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

Reviewed: https://review.opendev.org/674971
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=c1e896e733bb1eab985bf34762b3930f70777565
Submitter: Zuul
Branch: stable/ocata

commit c1e896e733bb1eab985bf34762b3930f70777565
Author: zhouhenglc <email address hidden>
Date: Tue Jul 30 19:57:18 2019 +0800

    fix update port bug

    when update port set body={"port": {}}, neutron server will return 500.

    In function _process_port_binding_attributes(plugins/ml2/plugin.py),
    when update port body={"port": {}}
    attrs={}
    vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
    vnic_type = {}
    because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE)
    vnic_type will be replicated as attrs.

    Change-Id: I40d388543387ebdd72f26d761339c1829bef9413
    Partial-bug: #1838396
    (cherry picked from commit dd080c70b423a56a69abf7e52d1fee0cb7988c92)

tags: added: in-stable-ocata
Changed in neutron:
status: In Progress → Fix Released
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.