Agent does not rejoin the Swarm agent cluster after overlay connectivity returns
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, go, kubernetes
- Domain
- backend, distributed-systems
Research direction
Start with serf/cluster.go, especially the startup Join attempt cited in the issue, and check how the agent discovers peers after an initial failure. The issue points to Serf's reconnect behavior in v0.8.3 as relevant context. Reproduce the blocked-overlay startup, restore connectivity, and confirm the agent rejoins without a restart and the reported cluster membership and /info requests recover.
Written by the indexing model from the issue text.
Description
A Portainer Agent remains outside the agent cluster even though its container is running and /ping returns 204. Restarting only the affected agent restores membership and access through Portainer.
Reproduction and observations
-
Start with a working multi-node Swarm and Portainer agents.
-
On one test worker, temporarily block inbound and outbound VXLAN traffic.
iptables -I INPUT 1 -p udp --dport 4789 -j DROP iptables -I OUTPUT 1 -p udp --dport 4789 -j DROP -
Stop its agent container and let Swarm create a replacement.
-
Keep the network blocked until the new agent starts its API. In my test, DNS returned peer addresses and DROP counters increased, but the agent logged only its own join. About five minutes later, while still blocked, its API started. Identities below are placeholders:
[INFO] serf: EventMemberJoin: worker-a-111111111111 192.0.2.10 INF github.com/portainer/agent/http/server.go:96 > starting Agent API server | api_version=2.27.9 server_addr=0.0.0.0 server_port=9001 use_tls=true -
Remove the block:
iptables -D INPUT -p udp --dport 4789 -j DROP iptables -D OUTPUT -p udp --dport 4789 -j DROP -
Check recovery. After the block was removed, both rules were absent, the same process was running, and
/pingon 9001 returned 204 and TCP 7946 connected in both directions between the agent's network namespace and a manager. Yet no further joins appeared, and the agent logged:ERR github.com/portainer/agent/http/handler/docker/docker_operation.go:70 > unable to redirect request to a manager node: no manager node found | request=/infoThe cluster diagnostic reported only this agent as
notInCluster. The membership gap was visible from both sides:-
Other agents could not find the affected worker. Targeted Inspect (
nodeNameandX-PortainerAgent-Target) returned HTTP 500:{"message":"The agent was unable to contact any other agent","details":"Unable to find the targeted agent"} -
The affected worker could not find a manager to handle
/info. Opening the environment in the WebUI failed with Failed loading environment / Unable to connect to the Docker environment (this was the original symptom that prompted this issue):Of 32 requests to
/api/endpoints/7/docker/v1.41/info, 15 returned HTTP 500, while 17 succeeded:{"message":"The agent was unable to contact any other agent located on a manager node","details":"Unable to find an agent on any manager node"}
Port 9001 is published in ingress mode; an ingress connection to the affected worker was present during the failures.
-
-
Stop only the affected agent again. After Swarm replaced it, membership was restored and targeted Inspect of the replacement returned HTTP 200. All 32 of 32 subsequent
/inforequests returned HTTP 200. No Docker daemon or host restart was needed.
Expected: the agent rejoins after connectivity returns, without an operator restart.
Environment
- Portainer Agent 2.27.9, deployed as a global Swarm service; all other agents run the same version.
- Docker Engine 28.1.1, Linux.
- Portainer Server 2.28.1.
P.S. I know Portainer requires matching Agent and Server versions, but agents discover each other without involving the Server. I have also seen the same symptom on another cluster with matching versions, but that cluster isn't available for reproduction tests.
Cause analysis
In 2.27.9, startup attempts Join once and continues on failure. Serf reconnects only to previously known failed members, so an isolated startup appears to leave the agent without a recovery path.
- Dominant language
- Go
- Stars
- 596
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from portainer/agent
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
[Feature Request] Allow Portainer Agent to Ignore Swarm Mode When Used Only for Overlay NetworkingOpen
Difficulty 4/5 3-5 days Newbie friendliness 54/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
☢️ Bug v3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area/import-export area/projects concern/ux
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
go-vikunja/vikunja#4455 · 1 comment ·
Maintainers usually reply within 2 days
-
Dependabot PRs no longer merge automaticallyPossibly taken @dwisiswant0 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
projectdiscovery/urlfinder#160 ·
Maintainers usually reply within 1 day
-
database
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
chnm/legal-modernism#450 ·
Maintainers usually reply within 1 day
-
tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day