os-net-config throwing error when applying routes to interface/VLAN

Bug #1819212 reported by Dan Sneddon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-net-config
Fix Released
Critical
Dan Sneddon

Bug Description

Fairly recent changes to os-net-config allow simple changes like IP, MTU, netmask, or routes to be changed on the fly without restarting the interface. However, route updates to interfaces and VLANs are still causing interfaces to be restarted due to an error.

The error encountered is:

Object "route add 172.33.9.0/26 via 172.20.1.59 dev vlan100" is unknown, try "ip help".

This can be duplicated by calling 'ip' with the parameters above passed as a string, such as:

# ip "route add 172.33.9.0/26 via 172.20.1.59 dev vlan100"

This appears to be due to an incorrect call to self.execute() where the command parameters are being passed as a string:

self.execute('Running ip %s' % command, ipcmd, command)

Instead, if we split the commands and pass it as a pointer to the list of args, that should work:

args = command.split()
self.execute('Running ip %s' % command, ipcmd, *args)

Dan Sneddon (dsneddon)
Changed in os-net-config:
importance: Undecided → Critical
status: New → In Progress
assignee: nobody → Dan Sneddon (dsneddon)
Revision history for this message
Dan Sneddon (dsneddon) wrote :

It turns out that this is a compound bug with two code errors. The first is the command-line parameters being passed as a string instead of a pointer to the args. The second is an incorrect filename in checking existing routes. This code:

            for interface in apply_routes:
                logger.debug('Applying routes for interface %s' % interface[0])
                commands = self.iproute2_route_commands(interface[0], interface[1])

is passing an interface name where it should be passing a filename. Here is the corrected code:

            for interface in apply_routes:
                logger.debug('Applying routes for interface %s' % interface[0])
                filename = self.root_dir + route_config_path(interface[1])
                commands = self.iproute2_route_commands(interface[0], filename)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to os-net-config (master)

Fix proposed to branch: master
Review: https://review.openstack.org/642182

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

Reviewed: https://review.openstack.org/642182
Committed: https://git.openstack.org/cgit/openstack/os-net-config/commit/?id=e912b02c3bec61ec3af610820601cc24b5dc1cba
Submitter: Zuul
Branch: master

commit e912b02c3bec61ec3af610820601cc24b5dc1cba
Author: Dan Sneddon <email address hidden>
Date: Fri Mar 8 15:46:34 2019 -0800

    Fix os-net-config interface restarts when applying routes

    There is a bug in the os-net-config code that applies updates to
    existing routes. Instead of deleting routes that no longer exist
    in the config and adding routes on the fly that do, the process
    always fails so the interface gets restarted.

    This change fixes the external call to "/sbin/ip", but also
    fixes a bug where the name of the file containing the stored
    routes was being passed incorrectly. This caused os-net-config
    to always think there were no routes present, and to apply the
    new route without deleting the old route. This can lead to an
    error if the routes conflict.

    Change-Id: I4315e9812c641a667a1d5c6529cdba5d2f5bf640
    Closes-bug: 1819212

Changed in os-net-config:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to os-net-config (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.openstack.org/642847

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-net-config (stable/rocky)

Reviewed: https://review.openstack.org/642847
Committed: https://git.openstack.org/cgit/openstack/os-net-config/commit/?id=21dfd95bbe8268ddc30cefc5ac5ea92a573d5155
Submitter: Zuul
Branch: stable/rocky

commit 21dfd95bbe8268ddc30cefc5ac5ea92a573d5155
Author: Dan Sneddon <email address hidden>
Date: Fri Mar 8 15:46:34 2019 -0800

    Fix os-net-config interface restarts when applying routes

    There is a bug in the os-net-config code that applies updates to
    existing routes. Instead of deleting routes that no longer exist
    in the config and adding routes on the fly that do, the process
    always fails so the interface gets restarted.

    This change fixes the external call to "/sbin/ip", but also
    fixes a bug where the name of the file containing the stored
    routes was being passed incorrectly. This caused os-net-config
    to always think there were no routes present, and to apply the
    new route without deleting the old route. This can lead to an
    error if the routes conflict.

    Change-Id: I4315e9812c641a667a1d5c6529cdba5d2f5bf640
    Closes-bug: 1819212
    (cherry picked from commit e912b02c3bec61ec3af610820601cc24b5dc1cba)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to os-net-config (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.openstack.org/643041

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/os-net-config 10.3.0

This issue was fixed in the openstack/os-net-config 10.3.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-net-config (stable/queens)

Reviewed: https://review.openstack.org/643041
Committed: https://git.openstack.org/cgit/openstack/os-net-config/commit/?id=f26718f557f7bf8940d60795d42e4552917363e4
Submitter: Zuul
Branch: stable/queens

commit f26718f557f7bf8940d60795d42e4552917363e4
Author: Dan Sneddon <email address hidden>
Date: Fri Mar 8 15:46:34 2019 -0800

    Fix os-net-config interface restarts when applying routes

    There is a bug in the os-net-config code that applies updates to
    existing routes. Instead of deleting routes that no longer exist
    in the config and adding routes on the fly that do, the process
    always fails so the interface gets restarted.

    This change fixes the external call to "/sbin/ip", but also
    fixes a bug where the name of the file containing the stored
    routes was being passed incorrectly. This caused os-net-config
    to always think there were no routes present, and to apply the
    new route without deleting the old route. This can lead to an
    error if the routes conflict.

    Change-Id: I4315e9812c641a667a1d5c6529cdba5d2f5bf640
    Closes-bug: 1819212
    (cherry picked from commit e912b02c3bec61ec3af610820601cc24b5dc1cba)
    (cherry picked from commit 21dfd95bbe8268ddc30cefc5ac5ea92a573d5155)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/os-net-config 9.4.0

This issue was fixed in the openstack/os-net-config 9.4.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/os-net-config 8.5.0

This issue was fixed in the openstack/os-net-config 8.5.0 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.