fix: preserve runtime address order for local icon lookup

This commit is contained in:
VAIO73
2026-10-18 18:50:54 +00:00
parent e63ec2ad7b
commit 6c269bf7a5
2 changed files with 17 additions and 1 deletions
+5 -1
View File
@@ -94,7 +94,11 @@ def _origin(vmid, payload):
for a in interface.get('addr_info', []) if 'local' in a}
except (ValueError, TypeError, KeyError) as exc:
raise IconError('host address check unavailable') from exc
addresses = sorted({str(ipaddress.ip_address(ip)) for ip in ips if _private_ip(ip)}, key=lambda ip: ':' in ip)
# Preserve lxc-info's reported order (CT215: eth0 then Docker bridges).
# Unordered set iteration selected an internal bridge at random. Keep
# runtime order within each address family, including when deduplicating.
addresses = list(dict.fromkeys(str(ipaddress.ip_address(ip)) for ip in ips if _private_ip(ip)))
addresses.sort(key=lambda ip: ':' in ip)
addresses = [ip for ip in addresses if ip not in host_ips]
if not addresses:
raise IconError('container has no isolated private address')