Skip to content

Commit

Permalink
fix: remove verbose logging admission-webhook
Browse files Browse the repository at this point in the history
After disabling HTTP2 connections by default in prometheus-operator#6028
started seeing verbose logging in admission webhook pods like:

`ts=2023-11-06T01:50:34.601774794Z caller=stdlib.go:105 caller=server.go:3215 msg="http: superfluous response.WriteHeader call from main.newSrv.func1 (main.go:173)"
`

Go doc says If WriteHeader is not called explicitly,
the first call to Write will trigger an implicit
WriteHeader(http.StatusOK).

This fix is to change the order of the method invocation
so log doesn't complain about this

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
(cherry picked from commit 374f4b3)
  • Loading branch information
slashpai committed Nov 6, 2023
1 parent 4b4a2a1 commit f43b281
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/admission-webhook/main.go
Expand Up @@ -169,8 +169,8 @@ func newSrv(logger log.Logger, tlsConf *tls.Config) *srv {
mux.Handle("/metrics", promhttp.HandlerFor(r, promhttp.HandlerOpts{}))

mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"status":"up"}`))
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"status":"up"}`))
})

httpServer := http.Server{
Expand Down

0 comments on commit f43b281

Please sign in to comment.