From d0a93f12d1ec1e2b276f9958898c9a6fe4f6b077 Mon Sep 17 00:00:00 2001 From: Matthew Salsamendi Date: Mon, 28 Aug 2023 16:15:06 -0700 Subject: [PATCH] client: include response body in output for successful HTTP checks (#18345) --- .changelog/18345.txt | 3 +++ client/serviceregistration/checks/client.go | 4 ---- client/serviceregistration/checks/client_test.go | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 .changelog/18345.txt 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", ), }}