mirror of
https://github.com/moby/moby.git
synced 2026-08-09 09:33:50 +00:00
A service's host-published ports are held by ref-counted reservations,
and both ways of getting the count wrong are silent. Releasing too
eagerly takes down a port that is still being served; not releasing at
all leaves the count non-zero, and the next service to publish that port
is told there is nothing to plumb and never becomes reachable. Neither
surfaces as an error from any API call, so nothing short of driving the
ports over the wire will catch it.
Follow a service's published ports through the two events that change
which reservations it holds. A published-port change leaves two
generations of the service alive at once, because the published-port set
is part of a service's identity, and the port they share must survive the
old one draining. Removing the service has to release the reservations
for good, which is checked by having a fresh service claim the same two
ports afterwards - the unpublishing has no other observable output.
This also covers the fix in 187436faf2,
which merged without a test: with it reverted, this test fails on the
port added by the update, because the arriving generation of the service
finds the VIP alias already present and gives up before publishing.
Signed-off-by: Cory Snider <csnider@mirantis.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>