App Framework S3 client leaks one idle connection per poll; pod runs out of ports and apps stop installing
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- aws, go, kubernetes
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
Bắt đầu với pkg/splunk/client/storage/aws/s3client.go và theo dõi cách InitClientConfig tạo các transport cho mỗi lần thăm dò kho ứng dụng; so sánh cách thiết lập transport trong pkg/splunk/client/splunk/splunkclient.go. Thêm kiểm tra hồi quy cho các kết nối nhàn rỗi và chạy các bài kiểm thử Go liên quan. Hoàn thành khi các lần thăm dò lặp lại không còn để lại một kết nối S3 nhàn rỗi cho mỗi lần thăm dò.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Go
- Star
- 260
- Fork
- 134
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của splunk/splunk-operator
-
monitoring console
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
splunk/splunk-operator#1887 ·
-
monitoring console
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
splunk/splunk-operator#1886 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 66/100
splunk/splunk-operator#1885 ·
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 52/100
splunk/splunk-operator#1884 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
splunk/splunk-operator#1883 ·
Tất cả issue của splunk/splunk-operator
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
FrederickFrance/igiveyouarendezvous#43 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
liftbridge-io/liftbridge#527 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày