Skip to content

Commit

Permalink
server: update healthz to return 200 instead of 204
Browse files Browse the repository at this point in the history
Returning 204 `StatusNoContent` for `/healthz` is technically the correct response. And on AWS [1] the health checks treat 200 to 399
as Healthy.
But on Azure, the health checks on treat 200 `StatusOK` [2] as the healthy response. :shake_fist:

This moves the ign server to return 200 for `/heathz`

[1]: https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-health-checks.html
[2]: https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-custom-probe-overview#httpprobe
  • Loading branch information
abhinavdahiya committed May 9, 2019
1 parent f36fd0b commit d7eeed1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ type healthHandler struct{}
func (h *healthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", "0")
if r.Method == http.MethodGet || r.Method == http.MethodHead {
w.WriteHeader(http.StatusNoContent)
w.WriteHeader(http.StatusOK)
return
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/server/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestHealthzHandler(t *testing.T) {
return new(ignv2_2types.Config), nil
},
checkResponse: func(t *testing.T, response *http.Response) {
checkStatus(t, response, http.StatusNoContent)
checkStatus(t, response, http.StatusOK)
checkContentLength(t, response, 0)
checkBodyLength(t, response, 0)
},
Expand All @@ -118,7 +118,7 @@ func TestHealthzHandler(t *testing.T) {
return new(ignv2_2types.Config), nil
},
checkResponse: func(t *testing.T, response *http.Response) {
checkStatus(t, response, http.StatusNoContent)
checkStatus(t, response, http.StatusOK)
checkContentLength(t, response, 0)
checkBodyLength(t, response, 0)
},
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestAPIServer(t *testing.T) {
return new(ignv2_2types.Config), nil
},
checkResponse: func(t *testing.T, response *http.Response) {
checkStatus(t, response, http.StatusNoContent)
checkStatus(t, response, http.StatusOK)
checkContentLength(t, response, 0)
checkBodyLength(t, response, 0)
},
Expand All @@ -272,7 +272,7 @@ func TestAPIServer(t *testing.T) {
return new(ignv2_2types.Config), nil
},
checkResponse: func(t *testing.T, response *http.Response) {
checkStatus(t, response, http.StatusNoContent)
checkStatus(t, response, http.StatusOK)
checkContentLength(t, response, 0)
checkBodyLength(t, response, 0)
},
Expand Down

0 comments on commit d7eeed1

Please sign in to comment.