Delete subnet can fail for SLAAC/DHCP_STATELESS with 409

Bug #1414199 reported by Salvatore Orlando
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Salvatore Orlando

Bug Description

The routine for deleting a subnet checks whether it's ok to remove a subnet in the following way:

1) Query IP allocations on the subnet for ports that can be automatically deleted
2) Remove those allocations
3) Check again subnet allocations. If there is any other allocation this means that there are some IPs that cannot be automatically deleted
4) Raise a conflict exception

In the case of SLAAC or DHCP_STATELESS IPv6 subnets, every IP address can be automatically deleted - and that's where the problem lies.
Indeed the query performed at step #3 [1] and [2] for ML2 plugin, might cause a failure during subnet deletion if:
- The transaction isolation level is set to READ COMMITTED
- The subnet address mode is either SLAAC or DHCP STATELESS
- A port is created concurrently with the delete subnet procedure and an IP address is assigned to it.

These circumstances are quite unlikely to occur, but far from impossible. They are indeed seen in gate tests [3].

It is advisable to provide a fix for this issue. To this aim it is probably worth noting that the check #3 is rather pointless for subnets with automatic address mode.

[1] http://git.openstack.org/cgit/openstack/neutron/tree/neutron/db/db_base_plugin_v2.py#n1240
[2] http://git.openstack.org/cgit/openstack/neutron/tree/neutron/plugins/ml2/plugin.py#n810
[3] http://logstash.openstack.org/#eyJzZWFyY2giOiJtZXNzYWdlOlwiVW5hYmxlIHRvIGNvbXBsZXRlIG9wZXJhdGlvbiBvbiBzdWJuZXRcIiBBTkQgbWVzc2FnZTpcIk9uZSBvciBtb3JlIHBvcnRzIGhhdmUgYW4gSVAgYWxsb2NhdGlvbiBmcm9tIHRoaXMgc3VibmV0XCIgQU5EIHRhZ3M6Y29uc29sZSBBTkQgYnVpbGRfc3RhdHVzOkZBSUxVUkUgQU5EIGJ1aWxkX25hbWU6XCJjaGVjay1ncmVuYWRlLWRzdm0tbmV1dHJvblwiIiwiZmllbGRzIjpbXSwib2Zmc2V0IjowLCJ0aW1lZnJhbWUiOiIxNzI4MDAiLCJncmFwaG1vZGUiOiJjb3VudCIsInRpbWUiOnsidXNlcl9pbnRlcnZhbCI6MH0sInN0YW1wIjoxNDIyMDQ1MDA1OTE3LCJtb2RlIjoiIiwiYW5hbHl6ZV9maWVsZCI6IiJ9

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

Changed in neutron:
status: New → In Progress
Changed in neutron:
importance: Undecided → Medium
importance: Medium → High
tags: added: gate-failure ipv6
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

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

commit 939f55822615bb352d86d575fbdf50337be6c8a8
Author: Salvatore Orlando <email address hidden>
Date: Fri Jan 23 13:51:15 2015 -0800

    Do not check twice IP allocations for auto-address subnets

    For auto-address subnets such as those with SLAAC and DHCP_STATELESS
    address modes it is ok to delete them even when there are active IP
    allocations.

    The current logic might trigger unexpected 409 errors if IP
    allocations are made on these subnets concurrently with their
    deletion.

    This patch simply ensures the final check for active IP allocations is
    not performed for this class of subnets; since all IP allocations will
    be removed anyway, it does not make sense to check whether there are
    allocations at all. In fact, doing this check might cause a failure
    of the delete operation if an IP allocation is made concurrently.

    This patch also factors out the logic for checking whether there are
    IP allocations on the subnet to avoid code duplication.

    Closes-Bug: #1414199

    Change-Id: I1c4ca6f677845f6e2e8d88f3629c0e91ca73b5d0

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Revision history for this message
Eran Kuris (ekuris) wrote :

How to reproduce :
Did you try to delete slaac/ stateless and you get 409 error or you did something else ?

Thierry Carrez (ttx)
Changed in neutron:
milestone: kilo-2 → 2015.1.0
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.