From 8f2aa3e0f5c528acbf01bdcf591cbff6b5898b35 Mon Sep 17 00:00:00 2001 From: Rob Murray Date: Tue, 25 Nov 2025 16:41:18 +0000 Subject: [PATCH] Network disconnect: log rather than error on gateway update During a network disconnect, log rather than returning an error if it's not possible to set up a new gateway. This restores the behaviour from before commit 53390f8 ("Put clearNetworkResources() inline in its only caller"). It's not ideal, but by the time new gateways are selected the old endpoint has been disconnected - and nothing puts things back. Until that's cleaned up, a broken state is inevitable, but letting endpoint deletion complete means the container can be restarted or re-connected to the network without a zombie endpoint causing further issues. Signed-off-by: Rob Murray --- daemon/libnetwork/endpoint.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/daemon/libnetwork/endpoint.go b/daemon/libnetwork/endpoint.go index 77ac5f95bf..52afdb4205 100644 --- a/daemon/libnetwork/endpoint.go +++ b/daemon/libnetwork/endpoint.go @@ -745,10 +745,12 @@ func (ep *Endpoint) Leave(ctx context.Context, sb *Sandbox) error { func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, n *Network, force bool) error { ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{ - "nid": n.ID(), + "nid": stringid.TruncateID(n.ID()), "net": n.Name(), - "eid": ep.ID(), + "eid": epShortId(ep), "ep": ep.Name(), + "sid": stringid.TruncateID(sb.ID()), + "cid": stringid.TruncateID(sb.ContainerID()), })) sb.mu.Lock() @@ -829,7 +831,13 @@ func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, n *Network, force if needNewGwEp { gwepAfter4, gwepAfter6 = sb.getGatewayEndpoint() if err := sb.updateGateway(gwepAfter4, gwepAfter6); err != nil { - return fmt.Errorf("updating gateway endpoint: %w", err) + // Don't return an error here without adding proper rollback of the work done above. + // See https://github.com/moby/moby/issues/51578 + log.G(ctx).WithFields(log.Fields{ + "gw4": epShortId(gwepAfter4), + "gw6": epShortId(gwepAfter6), + "error": err, + }).Warn("Configuring gateway after network disconnect") } }