Support 3xx HTTP status codes for health check
This commit is contained in:
parent
c09febfffc
commit
d6d795e286
3 changed files with 12 additions and 4 deletions
|
@ -203,8 +203,8 @@ func checkHealth(serverURL *url.URL, backend *BackendHealthCheck) error {
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
|
||||
return fmt.Errorf("received non-2xx status code: %v", resp.StatusCode)
|
||||
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {
|
||||
return fmt.Errorf("received error status code: %v", resp.StatusCode)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -47,6 +47,14 @@ func TestSetBackendsConfiguration(t *testing.T) {
|
|||
expectedNumUpsertedServers: 0,
|
||||
expectedGaugeValue: 1,
|
||||
},
|
||||
{
|
||||
desc: "healthy server staying healthy (StatusPermanentRedirect)",
|
||||
startHealthy: true,
|
||||
healthSequence: []int{http.StatusPermanentRedirect},
|
||||
expectedNumRemovedServers: 0,
|
||||
expectedNumUpsertedServers: 0,
|
||||
expectedGaugeValue: 1,
|
||||
},
|
||||
{
|
||||
desc: "healthy server becoming sick",
|
||||
startHealthy: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue