IMHO, this should also be fixed in cloud-init. If the input netplan contains "global" routes, the renderer (or whatever can pre-process the Netplan before renderering) should intelligently determine which interfaces have an on-link gateway that matches the global route, and automatically render the route at interface scope instead of "global".
Arguably, if the route's gateway address doesn't match an on-link prefix, it should not be installed anyway (the kernel will reject it anyway, unless the `onlink` flag is supplied, which instructs the kernel to assume the address is on-link even if it doesn't appear to be). But the only useful scenario I can see for supporting the `onlink` flag is if we're installing a route on an interface that will get is IP address via DHCP. ** Also affects: cloud-init Importance: Undecided Status: New -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to cloud-init. https://bugs.launchpad.net/bugs/1758919 Title: Static routes are not per-interface, which breaks some deployments Status in cloud-init: New Status in MAAS: In Progress Status in MAAS 2.3 series: Triaged Bug description: When juju tries to deploy a lxd container on a maas managed machine, it looses all static routes, due to ifdown/ifup being issued and e/n/i has no saved data on the original state. Machine with no lxd container deployed: root@4-compute-4:~# ip r default via 100.68.4.254 dev bond2 onlink 100.68.4.0/24 dev bond2 proto kernel scope link src 100.68.4.1 100.68.5.0/24 via 100.68.4.254 dev bond2 100.68.6.0/24 via 100.68.4.254 dev bond2 100.84.4.0/24 dev bond1 proto kernel scope link src 100.84.4.2 100.84.5.0/24 via 100.84.4.254 dev bond1 100.84.6.0/24 via 100.84.4.254 dev bond1 100.99.4.0/24 dev bond0 proto kernel scope link src 100.99.4.101 100.99.5.0/24 via 100.99.4.254 dev bond0 100.99.6.0/24 via 100.99.4.254 dev bond0 100.107.0.0/24 via 100.99.4.254 dev bond0 After juju deploys a container, routes are disappearing: root@4-management-1:~# ip r default via 100.68.100.254 dev bond2 onlink 10.177.144.0/24 dev lxdbr0 proto kernel scope link src 10.177.144.1 100.68.100.0/24 dev bond2 proto kernel scope link src 100.68.100.26 100.84.4.0/24 dev br-bond1 proto kernel scope link src 100.84.4.1 100.99.4.0/24 dev br-bond0 proto kernel scope link src 100.99.4.3 After host reboot, the routes are NOT getting back in place, they are still gone: root@4-management-1:~# ip r s default via 100.68.100.254 dev bond2 onlink 100.68.100.0/24 dev bond2 proto kernel scope link src 100.68.100.26 100.84.4.0/24 dev br-bond1 proto kernel scope link src 100.84.4.1 100.84.5.0/24 via 100.84.4.254 dev br-bond1 100.84.6.0/24 via 100.84.4.254 dev br-bond1 100.99.4.0/24 dev br-bond0 proto kernel scope link src 100.99.4.3 To manage notifications about this bug go to: https://bugs.launchpad.net/cloud-init/+bug/1758919/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp