Skip to content

Commit 6fa6978

Browse files
committed
Rename to healthz, make response JSON
1 parent 6cbae6d commit 6fa6978

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

test/integration/wfe_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ func TestWFEHTTPMetrics(t *testing.T) {
5353
resp.Body.Close()
5454
}
5555

56-
// TestWFEHealth checks to make sure that the /health endpoint returns 200 OK,
56+
// TestWFEHealthz checks to make sure that the /health endpoint returns 200 OK,
5757
// retrying in case overrides take a moment to load.
58-
func TestWFEHealth(t *testing.T) {
58+
func TestWFEHealthz(t *testing.T) {
5959
retries := 0
6060
var status int
6161
for retries < 5 {
6262
time.Sleep(core.RetryBackoff(retries, time.Millisecond*2, time.Millisecond*50, 2))
63-
resp, err := http.Get("http://boulder.service.consul:4001/health")
64-
test.AssertNotError(t, err, "GET boulder-wfe2 health")
63+
resp, err := http.Get("http://boulder.service.consul:4001/healthz")
64+
test.AssertNotError(t, err, "GET boulder-wfe2 healthz")
6565
status = resp.StatusCode
6666
resp.Body.Close()
6767
if status == http.StatusOK {

wfe2/wfe.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const (
7171
getCertPath = "/get/cert/"
7272
getCertInfoPath = "/get/certinfo/"
7373
buildIDPath = "/build"
74-
healthPath = "/health"
74+
healthzPath = "/healthz"
7575
)
7676

7777
const (
@@ -426,7 +426,7 @@ func (wfe *WebFrontEndImpl) Handler(stats prometheus.Registerer, oTelHTTPOptions
426426
wfe.HandleFunc(m, getCertPath, wfe.Certificate, "GET")
427427
wfe.HandleFunc(m, getCertInfoPath, wfe.CertificateInfo, "GET")
428428
wfe.HandleFunc(m, buildIDPath, wfe.BuildID, "GET")
429-
wfe.HandleFunc(m, healthPath, wfe.HttpHealth, "GET")
429+
wfe.HandleFunc(m, healthzPath, wfe.Healthz, "GET")
430430

431431
// Endpoint for draft-ietf-acme-ari
432432
if features.Get().ServeRenewalInfo {
@@ -1803,8 +1803,12 @@ func (wfe *WebFrontEndImpl) BuildID(ctx context.Context, logEvent *web.RequestEv
18031803
}
18041804
}
18051805

1806-
// HttpHealth tells the requester whether we're ready to serve requests.
1807-
func (wfe *WebFrontEndImpl) HttpHealth(ctx context.Context, _ *web.RequestEvent, response http.ResponseWriter, _ *http.Request) {
1806+
type WfeHealthzResponse struct {
1807+
Details string
1808+
}
1809+
1810+
// Healthz tells the requester whether we're ready to serve requests.
1811+
func (wfe *WebFrontEndImpl) Healthz(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) {
18081812
status := http.StatusOK
18091813
details := "OK"
18101814

@@ -1813,9 +1817,13 @@ func (wfe *WebFrontEndImpl) HttpHealth(ctx context.Context, _ *web.RequestEvent,
18131817
details = "waiting for overrides"
18141818
}
18151819

1816-
response.Header().Set("Content-Type", "text/plain")
1817-
response.WriteHeader(status)
1818-
if _, err := fmt.Println(response, details); err != nil {
1820+
jsonResponse, err := json.Marshal(WfeHealthzResponse{Details: details})
1821+
if err != nil {
1822+
wfe.log.Warningf("Could not marshal healthz response: %s", err)
1823+
}
1824+
1825+
err = wfe.writeJsonResponse(response, logEvent, status, jsonResponse)
1826+
if err != nil {
18191827
wfe.log.Warningf("Could not write response: %s", err)
18201828
}
18211829
}

wfe2/wfe_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ func TestHTTPMethods(t *testing.T) {
10971097
},
10981098
{
10991099
Name: "Health path should be GET only",
1100-
Path: healthPath,
1100+
Path: healthzPath,
11011101
Allowed: getOnly,
11021102
},
11031103
{

0 commit comments

Comments
 (0)