Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change "20x" in HTTP health check error messages to "2xx" #565

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/layer-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ checks:
threshold: <failure threshold>

# Configures an HTTP check, which is successful if a GET to the
# specified URL returns a 20x status code.
# specified URL returns a 2xx status code.
#
# Only one of "http", "tcp", or "exec" may be specified.
http:
Expand Down
4 changes: 2 additions & 2 deletions internals/overlord/checkstate/checkers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
execWaitDelay = time.Second
)

// httpChecker is a checker that ensures an HTTP GET at a specified URL returns 20x.
// httpChecker is a checker that ensures an HTTP GET at a specified URL returns 2xx.
type httpChecker struct {
name string
url string
Expand Down Expand Up @@ -77,7 +77,7 @@ func (c *httpChecker) check(ctx context.Context) error {
details = strings.Join(lines, "\n")
}
return &detailsError{
error: fmt.Errorf("non-20x status code %d", response.StatusCode),
error: fmt.Errorf("non-2xx status code %d", response.StatusCode),
details: details,
}
}
Expand Down
10 changes: 5 additions & 5 deletions internals/overlord/checkstate/checkers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ func (s *CheckersSuite) TestHTTP(c *C) {
c.Assert(headers.Get("X-Name"), Equals, "Bob Smith")
c.Assert(headers.Get("User-Agent"), Equals, "pebble-test")

// Non-20x status code returns error
// Non-2xx status code returns error
chk = &httpChecker{url: server.URL + "/404"}
err = chk.check(context.Background())
c.Assert(err, ErrorMatches, "non-20x status code 404")
c.Assert(err, ErrorMatches, "non-2xx status code 404")
c.Assert(path, Equals, "/404")

// In case of non-20x status, short response body is fully included in error details
// In case of non-2xx status, short response body is fully included in error details
response = "error details"
chk = &httpChecker{url: server.URL + "/500"}
err = chk.check(context.Background())
c.Assert(err, ErrorMatches, "non-20x status code 500")
c.Assert(err, ErrorMatches, "non-2xx status code 500")
detailsErr, ok := err.(*detailsError)
c.Assert(ok, Equals, true)
c.Assert(detailsErr.Details(), Equals, "error details")
Expand All @@ -95,7 +95,7 @@ func (s *CheckersSuite) TestHTTP(c *C) {
response = output.String()
chk = &httpChecker{url: server.URL + "/500"}
err = chk.check(context.Background())
c.Assert(err, ErrorMatches, "non-20x status code 500")
c.Assert(err, ErrorMatches, "non-2xx status code 500")
detailsErr, ok = err.(*detailsError)
c.Assert(ok, Equals, true)
c.Assert(detailsErr.Details(), Matches, `(?s)line 1\n.*line 5\n\(\.\.\.\)`)
Expand Down
Loading