Agent does not rejoin the Swarm agent cluster after overlay connectivity returns

Aperta
#754 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, go, kubernetes

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

  1. Start with a working multi-node Swarm and Portainer agents.

  2. 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
    
  3. Stop its agent container and let Swarm create a replacement.

  4. 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
    
  5. Remove the block:

    iptables -D INPUT -p udp --dport 4789 -j DROP
    iptables -D OUTPUT -p udp --dport 4789 -j DROP
    
  6. Check recovery. After the block was removed, both rules were absent, the same process was running, and /ping on 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=/info
    

    The 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 (nodeName and X-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):

      screenshot-2026-11-12-01-01-03

      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.

  7. 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 /info requests 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.

Lingua principale
Go
Stelle
596
Fork
98
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di portainer/agent

Tutte le issue di portainer/agent

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.