[improvement] Magpie fails to detect primary interface (IndexError: list index out of range)

Bug #2017161 reported by Peter Jose De Sousa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
charm-magpie
New
Undecided
Unassigned

Bug Description

Hello,

When deploying to BGP networks with BIRD, magpie attempts to detect the primary interface with routes. This breaks the magpie logic as there are lines such as this:

ip route (actual CIDRs removed)
0.0.0.0/1 proto bird
        nexthop via x.x.x.x dev ens2f0np0 weight 1
        nexthop via y.y.y.1 dev ens2f1np1 weight 1
default via x.x.x.1 dev ens2f1np1
default via y.y.y.1 dev eno1 proto dhcp src z.z.z.17 metric 100
x,x,x,0/24 dev ens2f0np0 proto kernel scope link src x.x.x.17
y.y.y.0/24 dev ens2f1np1 proto kernel scope link src y.y.y.17
128.0.0.0/1 proto bird
        nexthop via x.x.x.1 dev ens2f0np0 weight 1
        nexthop via y.y.y.1 dev ens2f1np1 weight 1
u.u.u.u/24 via y.y.y.1 dev eno1
y.y.y.y via u.u.u.1 dev eno1 proto dhcp src u.u.u.17 metric 100
u.u.u.u via u.u.u.1 dev eno1 proto dhcp src u.u.u.17 metric 100
u.u.u.u via u.u.u.1 dev eno1 proto dhcp src u.u.u.17 metric 100
u.u.u.u via u.u.u.1 dev eno1 proto dhcp src u.u.u.17 metric 100
u.u.u.0/24 via u.u.u.1 dev eno1
u.u.u.0/24 dev eno1 proto kernel scope link src u.u.u.17 metric 100
u.u.u.1 dev eno1 proto dhcp scope link src u.u.u.17 metric 100

This happens due to this logic:

def check_nodes(nodes, iperf_client=False):
    cfg = hookenv.config()
    local_ip = hookenv.network_get("magpie")['ingress-addresses'][0]
    iface_lines = subprocess.check_output(["ip", "route", "show", "to",
                                           "match", local_ip]).decode()
    iface_lines = iface_lines.split('\n')
    for line in iface_lines:
        if re.match('.* via .*', line) is None:
            break

    primary_iface = str(line).split('dev')[1].split(' ')[1]

This will throw the error in the title: IndexError: list index out of range)

This bug is just to document this limitation/improvment. The code could likely use JSON instead of parsing lines, and in the optimum case support this BGP scenario.

Thanks,
Peter

Tags: bgp
tags: added: bgp
Revision history for this message
Peter Jose De Sousa (pjds) wrote :
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.