diff --git a/.changelog/18345.txt b/.changelog/18345.txt new file mode 100644 index 000000000..e692422c3 --- /dev/null +++ b/.changelog/18345.txt @@ -0,0 +1,3 @@ +```release-note:improvement +services: Include response body in output for successful HTTP checks when using Nomad native service discovery +``` diff --git a/client/serviceregistration/checks/client.go b/client/serviceregistration/checks/client.go index c4e785f30..c65d2851c 100644 --- a/client/serviceregistration/checks/client.go +++ b/client/serviceregistration/checks/client.go @@ -205,16 +205,12 @@ func (c *checker) checkHTTP(ctx context.Context, qc *QueryContext, q *Query) *st switch { case result.StatusCode == http.StatusOK: qr.Status = structs.CheckSuccess - qr.Output = "nomad: http ok" - return qr case result.StatusCode < http.StatusBadRequest: qr.Status = structs.CheckSuccess default: qr.Status = structs.CheckFailure } - // status code was not 200; read the response body and set that as the - // check result output content qr.Output = limitRead(result.Body) return qr diff --git a/client/serviceregistration/checks/client_test.go b/client/serviceregistration/checks/client_test.go index f601305cc..5fb7abe81 100644 --- a/client/serviceregistration/checks/client_test.go +++ b/client/serviceregistration/checks/client_test.go @@ -143,7 +143,7 @@ func TestChecker_Do_HTTP(t *testing.T) { structs.Healthiness, structs.CheckSuccess, http.StatusOK, - "nomad: http ok", + "200 ok", ), }, { name: "200 readiness", @@ -153,7 +153,7 @@ func TestChecker_Do_HTTP(t *testing.T) { structs.Readiness, structs.CheckSuccess, http.StatusOK, - "nomad: http ok", + "200 ok", ), }, { name: "500 healthiness", @@ -203,7 +203,7 @@ func TestChecker_Do_HTTP(t *testing.T) { structs.Healthiness, structs.CheckSuccess, http.StatusOK, - "nomad: http ok", + "200 ok", ), }}