App Framework S3 client leaks one idle connection per poll; pod runs out of ports and apps stop installing
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- aws, go, kubernetes
- Ambito
- backend, networking
Direzione di ricerca
Inizia da pkg/splunk/client/storage/aws/s3client.go e segui come InitClientConfig crea i trasporti per ogni polling del repository dell'app; confronta la configurazione del trasporto in pkg/splunk/client/splunk/splunkclient.go. Aggiungi un controllo di regressione per le connessioni inattive ed esegui i test Go pertinenti. Il risultato è raggiunto quando i polling ripetuti non lasciano più una connessione S3 inattiva per ogni polling.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
With the App Framework enabled on a SearchHeadCluster (S3 provider aws, an S3-compatible endpoint), the operator leaks one idle TCP connection to the S3 endpoint per app repo poll. After a few weeks the pod runs out of local ports, every bucket listing fails, and app uploads silently stop installing.
Environment
- Splunk Operator 3.0.0, and the same code in 3.2.0 (reproduced on 3.2.0 too)
- Kubernetes 1.35 (RKE2)
- App Framework: one SearchHeadCluster, one app source,
appsRepoPollIntervalSeconds: 61, S3-compatible object store over plain HTTP
What we saw
- After 23 days the operator pod had 28,355 TCP sockets open, against an ephemeral port range of
32768 60999(28,232 ports). - Every reconcile then failed listing the bucket:
dial tcp <s3-endpoint>:3900: connect: cannot assign requested address - The object store itself was healthy and reachable from other pods. Restarting the operator pod fixed it immediately.
- After a restart, open connections to the S3 endpoint grow by about one per minute (one per poll) and never drop: 5 after 10 min, 10 after 15 min, 33 after 48 min, 59 after about 100 min. At that rate the ports run out in roughly 20 days.
- Connections to splunkd (8089) also start a new transport per client but level off around 120 to 140, presumably because splunkd closes idle keep-alive connections. The S3 endpoint does not, so those accumulate.
Cause
InitClientConfig in pkg/splunk/client/storage/aws/s3client.go builds a new http.Transport (and http.Client) on every call, with no IdleConnTimeout:
tr := &http.Transport{
TLSClientConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
},
}
tr.ForceAttemptHTTP2 = true
httpClient := http.Client{
Transport: tr,
Timeout: httpClientTimeout * time.Second,
}
It is called for every app repo check (GetRemoteStorageClient logs creating the client on each poll). Each discarded transport keeps its idle keep-alive connection in its pool, and since IdleConnTimeout is 0 (no limit), the connection is never closed unless the server closes it.
NewSplunkClient in pkg/splunk/client/splunk/splunkclient.go has the same per-call transport pattern.
Suggested fix
Either of these, smallest first:
- Set an idle timeout on the transport, e.g.
IdleConnTimeout: 90 * time.Second(thehttp.DefaultTransportvalue), so abandoned pools close their connections. - Build the transport once (package level, or cached per endpoint) and reuse it across calls, which also restores connection reuse.
Calling tr.CloseIdleConnections() when the client is no longer needed would also work but is easier to miss on error paths.
Workaround
Restart the operator deployment periodically (we run a weekly kubectl rollout restart deployment splunk-operator-controller-manager).
- Lingua principale
- Go
- Stelle
- 260
- Fork
- 134
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di splunk/splunk-operator
-
monitoring console
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
splunk/splunk-operator#1887 ·
-
monitoring console
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
splunk/splunk-operator#1886 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 66/100
splunk/splunk-operator#1885 ·
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 52/100
splunk/splunk-operator#1884 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
splunk/splunk-operator#1883 ·
Tutte le issue di splunk/splunk-operator
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
FrederickFrance/igiveyouarendezvous#43 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
liftbridge-io/liftbridge#527 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno