Swarm LB backend updates reset host IPVS conn_reuse_mode, disrupting independent host IPVS director
Description
On Docker Engine 29.8.0 (3ce5872), an ordinary Swarm service backend addition sets the host network namespace net.ipv4.vs.conn_reuse_mode to 0 even though Docker's load-balancer IPVS service is in its separate LB sandbox namespace. Repeated writes during service rollouts override a host LVS-DR director's intentional conn_reuse_mode=2. In our three-node cluster a Keepalived IPVS health gate observed 0 on all nodes during an unstable service deploy and the active public VIP entered FAULT. One earlier VIP flap indirectly restarted the host DNS resolver and broke an offsite PostgreSQL backup. We saw 28 VI_1 FAULTs across the nodes since September 21; we do not assert that each historical fault has this same cause because the old gate lacked invariant logging.
Reproduce
- On a Swarm node running a host IPVS director, establish
sysctl -w net.ipv4.vs.conn_reuse_mode=2and recordreadlink /proc/1/ns/net,readlink /proc/$(pidof dockerd)/ns/net, and host sysctl. The dockerd namespace must equal the host's. - Roll a service with default VIP endpoint mode and an overlay backend, while polling the host sysctl and journaling the host IPVS gate. Our bapi unstable deploy #219 at 2026-09-24 11:58Z yielded
UNHEALTHY: net.ipv4.vs.conn_reuse_mode is 0, expected 2on all three nodes. On brovs1VI_1andVI_DEVOPSentered FAULT at 11:58:03Z and regained MASTER at :11. The original 02:05 incident predates invariant logging, so its precise invariant is unknown. - The host timer repairs this to 2 once per second but repeated resets can be sampled by a two-second Keepalived health check. The competing writes are visible even without any Docker daemon restart.
Source: service_linux.go:94-100,158-170 uses ipvs.New(sb.Key()) for the LB sandbox, then calls sb.osSbox.ApplyOSTweaks(sb.oslTypes) on every backend addition outside Namespace.InvokeFunc. namespace_linux.go:568-584 hardcodes mode 0, while knobs_linux.go:19-47 writes through the calling thread's /proc/sys. Namespace.InvokeFunc has the correct LockOSThread/netns.Set mechanism, but this call does not use it. No specific syscall trace was captured. Both 29.8.1 and master retain this behavior.
Expected behavior
Adding a backend to Docker's LB sandbox must not repeatedly overwrite the host namespace's unrelated IPVS policy. Apply sandbox-local tweaks inside the sandbox netns, and document or offer an opt-out for any genuinely required host-global tuning. This should protect hosts running their own IPVS director without changing Docker's sandbox behavior.
docker version
Client: Docker Engine - Community
Version: 29.8.0
API version: 1.56
Go version: go1.26.8
Git commit: 88096ef
Built: Thu Sep 3 21:50:08 2026
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 29.8.0
API version: 1.56 (minimum version 1.40)
Go version: go1.26.8
Git commit: 3ce5872
Built: Thu Sep 3 21:50:08 2026
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.3.5
GitCommit: 1294c24a7da8e5a793ed378161673abe94118892
runc:
Version: 1.5.1
GitCommit: v1.5.1-0-g8f2685a4
docker-init:
Version: 0.19.0
GitCommit: de40ad0docker info
Client: Docker Engine - Community
Version: 29.8.0
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.37.0
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v5.5.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 73
Running: 25
Paused: 0
Stopped: 48
Images: 1176
Server Version: 29.8.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: active
NodeID: <redacted>
Is Manager: true
ClusterID: <redacted>
Managers: 3
Nodes: 3
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: <redacted-ip>
Manager Addresses:
<redacted-ip>:2377
<redacted-ip>:2377
<redacted-ip>:2377
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 1294c24a7da8e5a793ed378161673abe94118892
runc version: v1.5.1-0-g8f2685a4
init version: de40ad0
Security Options:
apparmor
Profile: default
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.8.0-139-generic
Operating System: Ubuntu 24.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 48
Total Memory: 220.3GiB
Name: <redacted>
ID: <redacted>
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
<redacted-ip>:5000
::1/128
127.0.0.0/8
Live Restore Enabled: false
Default Address Pools:
Base: 10.10.0.0/16, Size: 24
Firewall Backend: iptables+firewalld
ReloadedAt: 2026-09-22T02:05:01+02:00
EnableUserlandProxy: true
UserlandProxyPath: /usr/bin/docker-proxyAdditional Info
PR #43146 in 2022 added an InvokeFunc application and explicitly retained the host ApplyOSTweaks call with the comment "Keep this just so performance is not changed". Is the host-wide reset still required on every backend addition, rather than once at daemon startup, and is there a supported opt-out? If namespace behavior depends on kernel version, which knobs need the host value? We want to retain conn_reuse_mode=2 for independent host LVS-DR tuple-reuse correctness (new SYN reusing a FIN_WAIT four-tuple must be rescheduled rather than routed to the old backend). We can test a proposed fix against an actual Swarm rollout.
Related performance report: #35082. Please do not treat this as an already-fixed thread scheduling race: the call site itself is outside the namespace transition.
Source: moby/moby