diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 592edd2..720a548 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -8,18 +8,18 @@ import ( "runtime" "time" - "cloud-proxy/internal/cloud/gcp" - "cloud-proxy/internal/cloud/gcp/gcpauth" - "cloud-proxy/internal/config" - "cloud-proxy/internal/healthz" - "cloud-proxy/internal/proxy" - "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" + + "cloud-proxy/internal/cloud/gcp" + "cloud-proxy/internal/cloud/gcp/gcpauth" + "cloud-proxy/internal/config" + "cloud-proxy/internal/healthz" + "cloud-proxy/internal/proxy" ) var ( diff --git a/internal/config/config.go b/internal/config/config.go index 26ad781..17113a4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -22,9 +22,9 @@ type Config struct { PodMetadata PodMetadata `mapstructure:"podmetadata"` - // MetricsAddress string `mapstructure:"metricsaddress"` + // MetricsAddress string `mapstructure:"metricsaddress"`. HealthAddress string `mapstructure:"healthaddress"` - Log Log `mapstructure:"log"` + Log Log `mapstructure:"log"` } // PodMetadata stores metadata for the pod, mostly used for logging and debugging purposes. diff --git a/internal/healthz/healthz.go b/internal/healthz/healthz.go index 641c115..30fddb3 100644 --- a/internal/healthz/healthz.go +++ b/internal/healthz/healthz.go @@ -3,6 +3,7 @@ package healthz import ( "encoding/json" "net/http" + "time" "github.com/sirupsen/logrus" ) @@ -23,10 +24,16 @@ func (hc *Server) Run(addr string) error { mux.HandleFunc("/readyz", hc.readyCheck) mux.HandleFunc("/livez", hc.liveCheck) - return http.ListenAndServe(addr, mux) + server := &http.Server{ + Addr: addr, + ReadHeaderTimeout: 3 * time.Second, + Handler: mux, + } + + return server.ListenAndServe() } -func (hc *Server) readyCheck(w http.ResponseWriter, r *http.Request) { +func (hc *Server) readyCheck(w http.ResponseWriter, _ *http.Request) { w.Header().Set("content-type", "application/json") // TODO: Implement proper readiness checks. @@ -49,7 +56,7 @@ func (hc *Server) readyCheck(w http.ResponseWriter, r *http.Request) { } } -func (hc *Server) liveCheck(w http.ResponseWriter, r *http.Request) { +func (hc *Server) liveCheck(w http.ResponseWriter, _ *http.Request) { w.Header().Set("content-type", "application/json") // TODO: Implement proper liveness checks.