router_centralized_snat not removed when router migrated from DVR to HA

Bug #1714251 reported by venkata anil
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Ihar Hrachyshka

Bug Description

When a router is migrated from DVR to HA, all ports related to DVR should be removed. But I still see port with device_owner router_centralized_snat not removed.

Steps to reproduce:
1) create a network n1, and subnet on this network with name sn1
2) create a DVR, attach it to sn1 through router interface add and set gateway(router-gateway-set public)
3) boot a vm on n1 and associate a floating ip
4) set admin-state to False i.e neutron router-update --admin-state-up False <router-id>
5) Now update the router to HA router i.e
   neutron router-update --distributed=False --ha=True <router-id>
6) neutron port-list and also
   "select * from ports where device_id="router-id";
   will show this "network:router_centralized_snat" port

Changed in neutron:
assignee: nobody → venkata anil (anil-venkata)
tags: added: l3-dvr-backlog l3-ha tempest
Revision history for this message
Swaminathan Vasudevan (swaminathan-vasudevan) wrote :

So are you converting from DVR non-HA to DVR-HA or converting DVR to legacy router HA.
Can you confirm.

Changed in neutron:
status: New → Incomplete
Revision history for this message
venkata anil (anil-venkata) wrote :

While debugging migration tests failures for gate-tempest-dsvm-neutron-dvr-multinode-scenario-ubuntu-xenial-nv job, I observed that snat port is not removed after cleanup of DVR router interface. I see this issue intermittently. Next time when I see the issue I will upload tempest logs.

Revision history for this message
venkata anil (anil-venkata) wrote :

I suspect below code

https://github.com/openstack/neutron/blob/master/neutron/db/l3_dvr_db.py#L542

        ports = [
            rp.port.id for rp in
            router.attached_ports.filter_by(
                    port_type=const.DEVICE_OWNER_ROUTER_SNAT)
            if rp.port
        ]

        c_snat_ports = self.l3plugin._core_plugin.get_ports(
            context,
            filters={'id': ports}
        )
Here get_ports() depends on router.attached_ports. If router.attached_ports got deleted(because of router delete immediately after interface delete API call) though port might still exist in DB, then get_ports() can't return snat ports.

Instead we can call get_ports directly i.e
        c_snat_ports = self.l3plugin._core_plugin.get_ports(
            context,
            filters={'device_owner': [const.DEVICE_OWNER_ROUTER_SNAT],
                     'device_id': [router_id]}
        )

I have seen this in my logs earlier(intermittent). If I hit this issue again I will attach logs.
Let this bug be in incomplete state till I get logs.

Changed in neutron:
status: Incomplete → New
Revision history for this message
venkata anil (anil-venkata) wrote :

This is a valid bug

description: updated
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/501717

Changed in neutron:
status: New → In Progress
Changed in neutron:
assignee: venkata anil (anil-venkata) → Ihar Hrachyshka (ihar-hrachyshka)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

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

commit 777fb2af455eea31f9c6ea1f0e260ee8d4d0dbd7
Author: venkata anil <email address hidden>
Date: Thu Sep 7 12:36:05 2017 +0000

    Remove csnat port when DVR migrated to non-DVR

    When a router is migrated from DVR to HA or DVR to centralized router,
    router_centralized_snat port still exists in DB. When the router is no
    more a DVR router, this port is useless and has to be removed from DB.

    This patch removes router_centralized_snat port when a router is
    migrated from DVR to other modes.

    Closes-Bug: 1714251
    Change-Id: I124514d021ff8539ac3a628907cb49611ef66d08

Changed in neutron:
status: In Progress → Fix Released
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/504034

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.openstack.org/504082

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

Reviewed: https://review.openstack.org/504082
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=4089a49d348f4dcfbf38ad8b8dc9672535202cc9
Submitter: Jenkins
Branch: stable/pike

commit 4089a49d348f4dcfbf38ad8b8dc9672535202cc9
Author: venkata anil <email address hidden>
Date: Thu Sep 7 12:36:05 2017 +0000

    Remove csnat port when DVR migrated to non-DVR

    When a router is migrated from DVR to HA or DVR to centralized router,
    router_centralized_snat port still exists in DB. When the router is no
    more a DVR router, this port is useless and has to be removed from DB.

    This patch removes router_centralized_snat port when a router is
    migrated from DVR to other modes.

    Closes-Bug: 1714251
    Change-Id: I124514d021ff8539ac3a628907cb49611ef66d08
    (cherry picked from commit 777fb2af455eea31f9c6ea1f0e260ee8d4d0dbd7)

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

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

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

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

commit 1cf6806043cee21ea4afb98c3d18e7b80fb11e80
Author: Dongcan Ye <email address hidden>
Date: Thu Sep 14 19:12:51 2017 +0800

    Add a test csnat port removing in DVR migration

    This is an additional test for deleting csnat port when
    migrating DVR router to HA router.

    Change-Id: I4a2365fe3a64b65034280558ffe6312d8dabd600
    Partial-Bug: #1714251

tags: added: neutron-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 12.0.0.0b1

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

tags: removed: neutron-proactive-backport-potential
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.