Skip to content

Commit 4151885

Browse files
committed
fix(kube-ovn): bound webhook server request timeouts
The webhook http.Server set no read, write, or idle timeout, so a client that opens a connection and sends headers slowly could hold a goroutine and file descriptor indefinitely. Add ReadHeaderTimeout, ReadTimeout, WriteTimeout, and IdleTimeout. Signed-off-by: IvanHunters <[email protected]>
1 parent 8baa449 commit 4151885

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • packages/system/kubeovn-webhook/images/kubeovn-webhook

‎packages/system/kubeovn-webhook/images/kubeovn-webhook/main.go‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"log"
66
"net/http"
7+
"time"
78
)
89

910
var (
@@ -33,9 +34,13 @@ func main() {
3334
}
3435

3536
server := &http.Server{
36-
Addr: ":8443",
37-
TLSConfig: tlsConfig,
38-
Handler: mux,
37+
Addr: ":8443",
38+
TLSConfig: tlsConfig,
39+
Handler: mux,
40+
ReadHeaderTimeout: 10 * time.Second,
41+
ReadTimeout: 30 * time.Second,
42+
WriteTimeout: 30 * time.Second,
43+
IdleTimeout: 60 * time.Second,
3944
}
4045

4146
log.Printf("Starting webhook server on %s", server.Addr)

0 commit comments

Comments
 (0)