Bulk IPv6 subnet create error

Bug #1822582 reported by Marceli Kuźmicz
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Oleg Bondarev

Bug Description

When trying to create bulk IPv6 subnet from .json file on devstack( ubuntu server 16.04, latest openstack master version ), it throws an 500 internal server error.

This only happens, when trying to create bulk IPv6 subnets in slaac and dhcp stateless modes and there is already another subnet on that specific network.

It works fine with dhcp stateful.

There is also no problem when trying to do this with "openstack subnet create" or without bulk .json file.

Here are reproduction steps:

$ . ~/devstack/openrc admin

$ openstack network create n1
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2019-04-01T11:49:40Z |
| description | |
| dns_domain | None |
| id | 435383ce-4189-43d9-b6dd-ac947a5f711c |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| location | Munch({'project': Munch({'domain_id': 'default', 'id': u'c83b8eb6f6de41d1867c2ce1a9864b86', 'name': 'demo', 'domain_name': None}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| mtu | 1450 |
| name | n1 |
| port_security_enabled | True |
| project_id | c83b8eb6f6de41d1867c2ce1a9864b86 |
| provider:network_type | vxlan |
| provider:physical_network | None |
| provider:segmentation_id | 29 |
| qos_policy_id | None |
| revision_number | 1 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2019-04-01T11:49:40Z |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

$ export MY_TOKEN=$(openstack token issue -c id -f value)
$ cat bulk_ipv4.json
{
"subnets": [
 {
 "cidr": "192.168.0.0/24",
 "ip_version": 4,
 "network_id": "435383ce-4189-43d9-b6dd-ac947a5f711c",
 "enable_dhcp": true,
 "name": "subnet1"
}
]
}

$ curl -H "X-Auth-Token: $MY_TOKEN" -X POST http://127.0.0.1:9696/v2.0/subnets -d @~/bulk_ipv4.json

$ cat bulk_ipv6.json
{
 "subnets": [
 {
 "name": "subnet12_v6",
 "network_id": "435383ce-4189-43d9-b6dd-ac947a5f711c",
 "gateway_ip": "fd00:2:1234::1",
 "ip_version": 6,
 "cidr": "fd00:2:1234::/64",
 "enable_dhcp": true,
 "ipv6_ra_mode": "slaac",
 "ipv6_address_mode": "slaac"
 }
]
}

$ curl -H "X-Auth-Token: $MY_TOKEN" -X POST http://127.0.0.1:9696/v2.0/subnets -d @~/bulkv6.json | jq
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 402 100 150 100 252 471 792 --:--:-- --:--:-- --:--:-- 794
{
  "NeutronError": {
    "message": "Request Failed: internal server error while processing your request.",
    "type": "HTTPInternalServerError",
    "detail": ""
  }
}

[Last few lines are from neutron server log]

Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation self._create_subnet_postcommit(context, result, net_db, ipam_sub)
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation File "/usr/local/lib/python2.7/dist-packages/neutron_lib/db/api.py", line 233, in wrapped
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation return method(*args, **kwargs)
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation File "/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 730, in _create_subnet_postcommit
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation self.update_port(context, port_id, port_info)
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation File "/opt/stack/neutron/neutron/common/utils.py", line 668, in inner
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation "transaction.") % f)
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation RuntimeError: Method <function update_port at 0x7f50c198ff50> cannot be called within a transaction.
Apr 01 13:55:37 vm neutron-server[10148]: ERROR neutron.pecan_wsgi.hooks.translation

tags: added: ipv6
tags: added: bulk
Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

Confirmed reproducer on current devstack (and also that plain openstack subnet create command works with similar parameters)

Changed in neutron:
importance: Undecided → Medium
status: New → Confirmed
Changed in neutron:
assignee: nobody → Bernard Cafarelli (bcafarel)
Changed in neutron:
assignee: Bernard Cafarelli (bcafarel) → Oleg Bondarev (obondarev)
Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
Lajos Katona (lajos-katona) wrote :

For some reason the link to the fix is not added:
https://review.opendev.org/653947

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/654956

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/654957

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/654958

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/654959

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

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

commit 14c76d31814b8e696349a1c00ba65ef2919b48af
Author: Oleg Bondarev <email address hidden>
Date: Fri Apr 19 17:00:22 2019 +0400

    Move subnet postcommit out of transaction for bulk create

    For auto-address IPv6 subnets postcommit has update port action
    if the net already has ports. This results in
    "cannot be called within a transaction" error for bulk IPv6 subnet
    create.

    Closes-Bug: #1822582
    Change-Id: Ia32ec4c11c0793e7df07dcce19c122b3c7f865e1

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/queens)

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

commit 861f85056e064d8c3da7ad95df91a9b1147e6247
Author: Oleg Bondarev <email address hidden>
Date: Fri Apr 19 17:00:22 2019 +0400

    Move subnet postcommit out of transaction for bulk create

    For auto-address IPv6 subnets postcommit has update port action
    if the net already has ports. This results in
    "cannot be called within a transaction" error for bulk IPv6 subnet
    create.

    Closes-Bug: #1822582
    Change-Id: Ia32ec4c11c0793e7df07dcce19c122b3c7f865e1
    (cherry picked from commit 14c76d31814b8e696349a1c00ba65ef2919b48af)

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

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

commit caf4f0616113c3ac57d05b2f1c082a237ad36cfd
Author: Oleg Bondarev <email address hidden>
Date: Fri Apr 19 17:00:22 2019 +0400

    Move subnet postcommit out of transaction for bulk create

    For auto-address IPv6 subnets postcommit has update port action
    if the net already has ports. This results in
    "cannot be called within a transaction" error for bulk IPv6 subnet
    create.

    Closes-Bug: #1822582
    Change-Id: Ia32ec4c11c0793e7df07dcce19c122b3c7f865e1
    (cherry picked from commit 14c76d31814b8e696349a1c00ba65ef2919b48af)

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

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

commit d080a805c178f227a9e2469d64daaa763b75289c
Author: Oleg Bondarev <email address hidden>
Date: Fri Apr 19 17:00:22 2019 +0400

    Move subnet postcommit out of transaction for bulk create

    For auto-address IPv6 subnets postcommit has update port action
    if the net already has ports. This results in
    "cannot be called within a transaction" error for bulk IPv6 subnet
    create.

    Closes-Bug: #1822582
    Change-Id: Ia32ec4c11c0793e7df07dcce19c122b3c7f865e1
    (cherry picked from commit 14c76d31814b8e696349a1c00ba65ef2919b48af)

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

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

commit fd88d5c1aa68af30f3119508645a423f90eb92e4
Author: Oleg Bondarev <email address hidden>
Date: Fri Apr 19 17:00:22 2019 +0400

    Move subnet postcommit out of transaction for bulk create

    For auto-address IPv6 subnets postcommit has update port action
    if the net already has ports. This results in
    "cannot be called within a transaction" error for bulk IPv6 subnet
    create.

    Closes-Bug: #1822582
    Change-Id: Ia32ec4c11c0793e7df07dcce19c122b3c7f865e1
    (cherry picked from commit 14c76d31814b8e696349a1c00ba65ef2919b48af)

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

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 14.0.2

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 12.1.0

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 15.0.0.0b1

This issue was fixed in the openstack/neutron 15.0.0.0b1 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron pike-eol

This issue was fixed in the openstack/neutron pike-eol release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.