Skip to content

Commit d07df3b

Browse files
author
Thomas Gosteli
committed
fix: enforce timeouts in the kubenurse http.Server to avoid possible goroutine/memory leaks
1 parent ebb0764 commit d07df3b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/kubenurse/server.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@ func New(ctx context.Context, k8s kubernetes.Interface) (*Server, error) {
4848

4949
server := &Server{
5050
http: http.Server{
51-
Addr: ":8080",
52-
Handler: mux,
51+
Addr: ":8080",
52+
Handler: mux,
53+
ReadHeaderTimeout: 5 * time.Second,
54+
WriteTimeout: 10 * time.Second,
55+
IdleTimeout: 120 * time.Second,
5356
},
5457
https: http.Server{
55-
Addr: ":8443",
56-
Handler: mux,
58+
Addr: ":8443",
59+
Handler: mux,
60+
ReadHeaderTimeout: 5 * time.Second,
61+
WriteTimeout: 10 * time.Second,
62+
IdleTimeout: 120 * time.Second,
5763
},
5864

5965
//nolint:goconst // No need to make "true" a constant in my opinion, readability is better like this.

0 commit comments

Comments
 (0)