networksegments table in neutron can not be cleared automatically

Bug #1807483 reported by yeshen on 2018-12-08
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Undecided
Unassigned

Bug Description

_process_port_binding function in neutron/plugins/ml2/plugin.py used clear_binding_levels to clear ml2_port_binding_levels table, but it will not do anything to networksegments under hierarchical port bonding condition

@db_api.context_manager.writer
def clear_binding_levels(context, port_id, host):
    if host:
        for l in (context.session.query(models.PortBindingLevel).
                  filter_by(port_id=port_id, host=host)):
            context.session.delete(l)
        LOG.debug("For port %(port_id)s, host %(host)s, "
                  "cleared binding levels",
                  {'port_id': port_id,
                   'host': host})

yeshen (yeshen1) wrote :

The revised method is as follows:

@db_api.context_manager.writer
def clear_binding_levels(context, port_id, host):
    if host:
        for l in (context.session.query(models.PortBindingLevel).
                  filter_by(port_id=port_id, host=host)):
            from neutron.db.models.segment import NetworkSegment
            for s in (context.session.query(NetworkSegment).
                      filter_by(id=l.segment_id, is_dynamic=1)):
                context.session.delete(s)
            context.session.delete(l)
        LOG.debug("For port %(port_id)s, host %(host)s, "
                  "cleared binding levels",
                  {'port_id': port_id,
                   'host': host})

Bence Romsics (bence-romsics) wrote :

Thank you for your bug report.

Before jumping into code changes could you please provide a description of the bug? Usually the following format is very useful for fellow maintainers:

1) reproducible steps of what you did
2) your expected outcome
3) the actual outcome

I also suggest pushing code change proposals to review.openstack.org which is much better suited to line-by-line discussion of code. Please see here:

https://docs.openstack.org/contributors/

Changed in neutron:
status: New → Incomplete
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers