yanger: Handle the case when a container interface can not be found

Due to #902 (which has not been root caused at this time), podman may
indicate the existance of an interface that yanger is not able to
locate in any namespace. Therefore, make sure that we verify that the
interface was actually found before trying to create the operational
data for it.
This commit is contained in:
Tobias Waldekranz
2025-01-22 14:11:37 +01:00
parent a640460baf
commit c2959cf41e
@@ -16,6 +16,8 @@ def find_interface(cifname):
ipaddrs = common.ipaddrs(ifname=iplink["ifname"], netns=ns["name"])
return (iplink, next(iter(ipaddrs.values())))
return (None, None)
def podman_interfaces():
interfaces = {}
@@ -31,6 +33,7 @@ def podman_interfaces():
return interfaces
def interfaces(ifname):
interfaces = []
@@ -39,6 +42,9 @@ def interfaces(ifname):
continue
iplink, ipaddr = find_interface(cifname)
if not (iplink and ipaddr):
continue
interface = link.interface_common(iplink, ipaddr)
# The original interface name is stored in ifalias by podman -