Regex parsing in get_vif_port_by_id is tedious and error prone

Bug #1280827 reported by Salvatore Orlando
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Salvatore Orlando

Bug Description

ovs-vsctl has a switch for returning json output, which is arguably better for machine processing, and therefore more suitable for neutron's OVS agent.

Indeed get_vif_port_set in neutron/agent/linux/ovs_lib.py already uses json output.
However, get_vif_port_by_id performs match on the text output from ovs_vsctl.
While it is true that regular expressions are extremely powerful, apparently trivial errors in the regular expression itself can lead to errors like [1].

In [1] the evaluation of a regular expression is failing because the name of a VIF was not wrapped in double quotes.
Even if the could be worth looking into ovs-vsctl output to understand in which cases VIF names are wrapped in quotes and in which not, it is probably better to just switch to JSON output as parsing JSON is easier and therefore less likely to cause errors.

It is also worth noting that the error in regex parsing [1] causes the VIF to not be wired triggering the same failure as bug 1253896.

[1] http://logs.openstack.org/49/63449/16/experimental/check-tempest-dsvm-neutron-isolated/de067c3/logs/screen-q-agt.txt.gz#_2014-02-16_11_46_14_830

Tags: ovs
summary: - Regex parsing in get_vif_port_by_id is tedious and error-prone
+ Regex parsing in get_vif_port_by_id is tedious and error prone
tags: added: ovs
removed: ops
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/73889

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.openstack.org/73889
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=3d24fe5710cbea6d7d1f88c3476f4a856347ab5e
Submitter: Jenkins
Branch: master

commit 3d24fe5710cbea6d7d1f88c3476f4a856347ab5e
Author: Salvatore Orlando <email address hidden>
Date: Sun Feb 16 15:47:34 2014 -0800

    Parse JSON in ovs_lib.get_vif_port_by_id

    This patch replaces regex matching of text output with parsing
    of JSON output in ovs_lib.get_vif_port_by_id.
    This makes the code more reliable as subtle, possibly even
    cosmetic, changes in ovs-vsctl output format could cause the
    regular expression match to fail.

    Also, this makes the code consistent with ovs_lib.get_vif_port_set
    which already uses JSON output.

    Finally this patch slightly changes the behaviour of
    ovs_lib.get_vif_port_by_id returning None if elements such as
    mac address or ofport were not available.

    Change-Id: Ia985a130739c72b5b88414a79b2c6083ca6a0a00
    Closes-Bug: #1280827

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: icehouse-3 → 2014.1
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.