mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
client: include response body in output for successful HTTP checks (#18345)
This commit is contained in:
committed by
GitHub
parent
f187afab9f
commit
d0a93f12d1
3
.changelog/18345.txt
Normal file
3
.changelog/18345.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:improvement
|
||||
services: Include response body in output for successful HTTP checks when using Nomad native service discovery
|
||||
```
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
),
|
||||
}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user