3 Commits

Author SHA1 Message Date
Mads Jon Nielsen
1143f413f6 libnetwork: ref-count service aliases for VIP DNS records
During rolling updates, VIP DNS records for service aliases were never
cleaned up when aliases were removed from the service spec. VIP alias
records were only added when the first backend joined a network
(addService=true) and only removed when the last backend left
(rmService=true). During rolling updates there is always at least one
backend, so neither condition triggered and stale aliases persisted.

Each container has its own service config, so there is no single
canonical alias list per service while a rolling update is in flight.
Instead, ref-count aliases per (network, alias) on each loadBalancer:
add the VIP DNS record on the 0->1 transition (first task on that
network claiming the alias) and remove it on the 1->0 transition (last
task referencing it has left). Ref counts are per-network because a
Swarm service can attach to multiple networks with different alias
sets, and a VIP DNS record only makes sense on the network that
actually has the alias configured.

Aliases now survive a rolling update for as long as any task -- old or
new -- still references them on that network, and new aliases register
as soon as the first task carrying them starts.

Signed-off-by: Mads Jon Nielsen <madsjon@gmail.com>
2026-05-12 14:37:09 +02:00
Cory Snider
21dd960a73 d/libnetwork: fix (*Controller).getLBIndex panics
Check the serviceBinding's deleted flag to guard against the service
getting deleted before we locked its mutex, which would make it futile
to look up the load balancers. And guard against dereferencing a nil
*loadBalancer in general.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2026-01-29 18:14:56 -05:00
Derek McGowan
7a720df61f Move libnetwork to daemon/libnetwork
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-14 09:25:23 -07:00