From 8588aa96156ec4408ec64d07d72341d174ba49d8 Mon Sep 17 00:00:00 2001 From: Philippe Boneff Date: Wed, 30 Oct 2024 15:05:37 +0000 Subject: [PATCH 1/3] Remove TLS support We don't need this for now. It was only added recently to the CTFE and got ported over here. In an effort to splify this binary to its bare minimum, let's remove this for now. We can always add it back later if required. --- cmd/gcp/main.go | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/cmd/gcp/main.go b/cmd/gcp/main.go index a16f7c4..b832154 100644 --- a/cmd/gcp/main.go +++ b/cmd/gcp/main.go @@ -17,7 +17,6 @@ package main import ( "context" - "crypto/tls" "flag" "fmt" "net/http" @@ -52,8 +51,6 @@ var ( notAfterLimit timestampFlag httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).") - tlsCert = flag.String("tls_certificate", "", "Path to server TLS certificate.") - tlsKey = flag.String("tls_key", "", "Path to server TLS private key.") metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will be visible on --http_endpoint.") tesseraDeadline = flag.Duration("tessera_deadline", time.Second*10, "Deadline for Tessera requests.") maskInternalErrors = flag.Bool("mask_internal_errors", false, "Don't return error strings with Internal Server Error HTTP responses.") @@ -165,20 +162,7 @@ func main() { } // Bring up the HTTP server and serve until we get a signal not to. - srv := http.Server{} - if *tlsCert != "" && *tlsKey != "" { - cert, err := tls.LoadX509KeyPair(*tlsCert, *tlsKey) - if err != nil { - klog.Errorf("failed to load TLS certificate/key: %v", err) - } - tlsConfig := &tls.Config{ - Certificates: []tls.Certificate{cert}, - MinVersion: tls.VersionTLS12, - } - srv = http.Server{Addr: *httpEndpoint, Handler: handler, TLSConfig: tlsConfig} - } else { - srv = http.Server{Addr: *httpEndpoint, Handler: handler} - } + srv := http.Server{Addr: *httpEndpoint, Handler: handler} shutdownWG := new(sync.WaitGroup) go awaitSignal(func() { shutdownWG.Add(1) @@ -194,14 +178,7 @@ func main() { klog.Info("HTTP server shutdown") }) - if *tlsCert != "" && *tlsKey != "" { - err = srv.ListenAndServeTLS("", "") - } else { - err = srv.ListenAndServe() - } - if err != http.ErrServerClosed { - klog.Warningf("Server exited: %v", err) - } + err = srv.ListenAndServe() // Wait will only block if the function passed to awaitSignal was called, // in which case it'll block until the HTTP server has gracefully shutdown shutdownWG.Wait() From af413de2ae04214d921487ab08ed657960cba7be Mon Sep 17 00:00:00 2001 From: Philippe Boneff Date: Wed, 30 Oct 2024 15:16:56 +0000 Subject: [PATCH 2/3] Add error checking back --- cmd/gcp/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/gcp/main.go b/cmd/gcp/main.go index b832154..38b485e 100644 --- a/cmd/gcp/main.go +++ b/cmd/gcp/main.go @@ -179,6 +179,9 @@ func main() { }) err = srv.ListenAndServe() + if err != http.ErrServerClosed { + klog.Warningf("Server exited: %v", err) + } // Wait will only block if the function passed to awaitSignal was called, // in which case it'll block until the HTTP server has gracefully shutdown shutdownWG.Wait() From be777530684c306cdd08b292cacf1780549755f5 Mon Sep 17 00:00:00 2001 From: Philippe Boneff Date: Thu, 31 Oct 2024 13:02:13 +0000 Subject: [PATCH 3/3] nitmergelines --- cmd/gcp/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/gcp/main.go b/cmd/gcp/main.go index 38b485e..d3b04dd 100644 --- a/cmd/gcp/main.go +++ b/cmd/gcp/main.go @@ -178,8 +178,7 @@ func main() { klog.Info("HTTP server shutdown") }) - err = srv.ListenAndServe() - if err != http.ErrServerClosed { + if err := srv.ListenAndServe(); err != http.ErrServerClosed { klog.Warningf("Server exited: %v", err) } // Wait will only block if the function passed to awaitSignal was called,