Root cause analysis shows that starting from netifaces v0.11.0:
1 - netifaces only considers routes as default if they are defined on the main table
2 - netifaces selects the route with the lowest metric(highest prio) to show as the "default"
3 - combining 1 and 2: if the default route with the lowest metric is not on the main table, netifaces.gateways()["default"] returns empty
4 - charm-advanced-routing introduces a new table called "apitable" upon installation with a default route on it
5 - the issue is observed when the default route with the lowest metric is not on the main table. Hence the error:
The issue can be resolved by any of the following:
- making sure the default route with the lowest metric is on the main table.
- pinning down the netifaces package
- proposing a patch to netifaces-plus if this _should_ not be the right behavior.(I am not exactly convinced that the default route MUST be in the main table..)
Relating the bug to the charm-advanced-routing project as well
Root cause analysis shows that starting from netifaces v0.11.0: gateways( )["default" ] returns empty routing introduces a new table called "apitable" upon installation with a default route on it
1 - netifaces only considers routes as default if they are defined on the main table
2 - netifaces selects the route with the lowest metric(highest prio) to show as the "default"
3 - combining 1 and 2: if the default route with the lowest metric is not on the main table, netifaces.
4 - charm-advanced-
5 - the issue is observed when the default route with the lowest metric is not on the main table. Hence the error:
iface = netifaces. gateways( )["default" ][netifaces. AF_INET] [1]
KeyError: 2
where 2 represents netifaces.AF_INET.
The issue can be resolved by any of the following:
- making sure the default route with the lowest metric is on the main table.
- pinning down the netifaces package
- proposing a patch to netifaces-plus if this _should_ not be the right behavior.(I am not exactly convinced that the default route MUST be in the main table..)
Relating the bug to the charm-advanced- routing project as well