neutron-remove-duplicated-port-bindings doesn't remove binding_levels

Bug #2000078 reported by Anton Kurbatov
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Rodolfo Alonso

Bug Description

I'm trying to do an INACTIVE port binding cleanup using neutron-remove-duplicated-port-bindings tool from #1979072
But I found an issue with this help tool: it doens't remove entries from the ml2_port_binding_levels table that still blocks new port binding to the host.

Demo:
1)
create VM and bind a port to another host:
$ openstack port create my-port --network private --device-owner compute:test
-> get port port ID -> 075c4058-2933-4f6f-90a9-f754e81cef52
$ curl -k -H "x-auth-token: $t" -H "Content-Type: application/json" -X POST http://10.136.16.186:9696/networking/v2.0/ports/075c4058-2933-4f6f-90a9-f754e81cef52/bindings -d '{"binding": {"host": "ak-dev2"}}'

MariaDB [neutron]> select port_id,host,vif_type,status from ml2_port_bindings where port_id='075c4058-2933-4f6f-90a9-f754e81cef52';
+--------------------------------------+---------+----------+----------+
| port_id | host | vif_type | status |
+--------------------------------------+---------+----------+----------+
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev1 | ovs | ACTIVE |
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev2 | ovs | INACTIVE |
+--------------------------------------+---------+----------+----------+
2 rows in set (0.000 sec)

MariaDB [neutron]> select * from ml2_port_binding_levels where port_id='075c4058-2933-4f6f-90a9-f754e81cef52';
+--------------------------------------+---------+-------+-------------+--------------------------------------+
| port_id | host | level | driver | segment_id |
+--------------------------------------+---------+-------+-------------+--------------------------------------+
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev1 | 0 | openvswitch | 2250e731-0046-46ae-8cf0-8da7fd3aad98 |
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev2 | 0 | openvswitch | 2250e731-0046-46ae-8cf0-8da7fd3aad98 |
+--------------------------------------+---------+-------+-------------+--------------------------------------+
2 rows in set (0.000 sec)

MariaDB [neutron]>

2) remove INACTIVE port bindings via neutron-remove-duplicated-port-bindings:
$ neutron-remove-duplicated-port-bindings --config-file /etc/neutron/neutron.conf

MariaDB [neutron]> select port_id,host,vif_type,status from ml2_port_bindings where port_id='075c4058-2933-4f6f-90a9-f754e81cef52';
+--------------------------------------+---------+----------+--------+
| port_id | host | vif_type | status |
+--------------------------------------+---------+----------+--------+
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev1 | ovs | ACTIVE |
+--------------------------------------+---------+----------+--------+
1 row in set (0.000 sec)

MariaDB [neutron]> select * from ml2_port_binding_levels where port_id='075c4058-2933-4f6f-90a9-f754e81cef52';
+--------------------------------------+---------+-------+-------------+--------------------------------------+
| port_id | host | level | driver | segment_id |
+--------------------------------------+---------+-------+-------------+--------------------------------------+
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev1 | 0 | openvswitch | 2250e731-0046-46ae-8cf0-8da7fd3aad98 |
| 075c4058-2933-4f6f-90a9-f754e81cef52 | ak-dev2 | 0 | openvswitch | 2250e731-0046-46ae-8cf0-8da7fd3aad98 |
+--------------------------------------+---------+-------+-------------+--------------------------------------+
2 rows in set (0.000 sec)

MariaDB [neutron]>

3) Create the port binding again. It fails:

$ # curl -k -H "x-auth-token: $t" -H "Content-Type: application/json" -X POST http://10.136.16.186:9696/networking/v2.0/ports/075c4058-2933-4f6f-90a9-f754e81cef52/bindings -d '{"binding": {"host": "ak-dev2"}}'
{"NeutronError": {"type": "NeutronDbObjectDuplicateEntry", "message": "Failed to create a duplicate PortBindingLevel: for attribute(s) ['PRIMARY'] with value(s) 075c4058-2933-4f6f-90a9-f754e81cef52-ak-dev2-0", "detail": ""}}

Changed in neutron:
importance: Undecided → Medium
assignee: nobody → Rodolfo Alonso (rodolfo-alonso-hernandez)
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/c/openstack/neutron/+/868301

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/868301
Committed: https://opendev.org/openstack/neutron/commit/572185e1fd252772d8baaec099bf8bedfc837013
Submitter: "Zuul (22348)"
Branch: master

commit 572185e1fd252772d8baaec099bf8bedfc837013
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon Dec 12 05:10:01 2022 +0100

    Delete the PB level registers when deleting the duplicated PB

    The ``neutron-remove-duplicated-port-bindings`` script removes the
    duplicated port binding registers ("ml2_port_bindings" table) that
    have status=INACTIVE.

    This patch also removes the corresponding port binding levels
    ("ml2_port_binding_levels" table) associated to those inactive port
    bindings.

    Closes-Bug: #2000078

    Change-Id: I12fa0764cd0ff509f1859b61060d64cc5a54a7b9

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

This issue was fixed in the openstack/neutron 22.0.0.0rc1 release candidate.

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

Fix proposed to branch: stable/zed
Review: https://review.opendev.org/c/openstack/neutron/+/877484

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

Fix proposed to branch: stable/yoga
Review: https://review.opendev.org/c/openstack/neutron/+/877485

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

Fix proposed to branch: stable/xena
Review: https://review.opendev.org/c/openstack/neutron/+/877492

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

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/neutron/+/877493

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/877484
Committed: https://opendev.org/openstack/neutron/commit/07855a68266484ae187c76708a727b8a4db1e2e2
Submitter: "Zuul (22348)"
Branch: stable/zed

commit 07855a68266484ae187c76708a727b8a4db1e2e2
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon Dec 12 05:10:01 2022 +0100

    Delete the PB level registers when deleting the duplicated PB

    The ``neutron-remove-duplicated-port-bindings`` script removes the
    duplicated port binding registers ("ml2_port_bindings" table) that
    have status=INACTIVE.

    This patch also removes the corresponding port binding levels
    ("ml2_port_binding_levels" table) associated to those inactive port
    bindings.

    Closes-Bug: #2000078

    Change-Id: I12fa0764cd0ff509f1859b61060d64cc5a54a7b9
    (cherry picked from commit 572185e1fd252772d8baaec099bf8bedfc837013)

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/877485
Committed: https://opendev.org/openstack/neutron/commit/833260b04d300500aa7b9d1b5f2915352fd5c1a3
Submitter: "Zuul (22348)"
Branch: stable/yoga

commit 833260b04d300500aa7b9d1b5f2915352fd5c1a3
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon Dec 12 05:10:01 2022 +0100

    Delete the PB level registers when deleting the duplicated PB

    The ``neutron-remove-duplicated-port-bindings`` script removes the
    duplicated port binding registers ("ml2_port_bindings" table) that
    have status=INACTIVE.

    This patch also removes the corresponding port binding levels
    ("ml2_port_binding_levels" table) associated to those inactive port
    bindings.

    Closes-Bug: #2000078

    Change-Id: I12fa0764cd0ff509f1859b61060d64cc5a54a7b9
    (cherry picked from commit 572185e1fd252772d8baaec099bf8bedfc837013)
    (cherry picked from commit 07855a68266484ae187c76708a727b8a4db1e2e2)

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/877492
Committed: https://opendev.org/openstack/neutron/commit/2fb9ddb01ed44fae19c0184baa8620e95e51e344
Submitter: "Zuul (22348)"
Branch: stable/xena

commit 2fb9ddb01ed44fae19c0184baa8620e95e51e344
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon Dec 12 05:10:01 2022 +0100

    Delete the PB level registers when deleting the duplicated PB

    The ``neutron-remove-duplicated-port-bindings`` script removes the
    duplicated port binding registers ("ml2_port_bindings" table) that
    have status=INACTIVE.

    This patch also removes the corresponding port binding levels
    ("ml2_port_binding_levels" table) associated to those inactive port
    bindings.

    Closes-Bug: #2000078

    Change-Id: I12fa0764cd0ff509f1859b61060d64cc5a54a7b9
    (cherry picked from commit 572185e1fd252772d8baaec099bf8bedfc837013)
    (cherry picked from commit 07855a68266484ae187c76708a727b8a4db1e2e2)

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/877493
Committed: https://opendev.org/openstack/neutron/commit/90786f9332790c94bc69ba3c0e907e661dc813b9
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 90786f9332790c94bc69ba3c0e907e661dc813b9
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon Dec 12 05:10:01 2022 +0100

    Delete the PB level registers when deleting the duplicated PB

    The ``neutron-remove-duplicated-port-bindings`` script removes the
    duplicated port binding registers ("ml2_port_bindings" table) that
    have status=INACTIVE.

    This patch also removes the corresponding port binding levels
    ("ml2_port_binding_levels" table) associated to those inactive port
    bindings.

    Closes-Bug: #2000078

    Conflicts:
        neutron/objects/ports.py

    Change-Id: I12fa0764cd0ff509f1859b61060d64cc5a54a7b9
    (cherry picked from commit 572185e1fd252772d8baaec099bf8bedfc837013)
    (cherry picked from commit 07855a68266484ae187c76708a727b8a4db1e2e2)

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

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

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

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

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

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

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

This issue was fixed in the openstack/neutron wallaby-eom 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.