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

Add last failure info to checks API and CLI command #134

Closed
wants to merge 3 commits into from

Conversation

benhoyt
Copy link
Contributor

@benhoyt benhoyt commented Aug 11, 2022

This is a similar but slightly cleaned up version of what we discussed here. We decided against it at the time, but now after having considered using changes/tasks and then events for check diagnostics, we've decided that it's probably better to separate out the events/hooks use case from the debugging use case, and we're back to having a simple way to view the check failures when debugging.

The response from the API now includes a last-failure key as follows (it's only present if failures is greater than 0):

{
  "name": "chk1",
  "status": "down",
  "failures": 1,
  "threshold": 1,
  "last-failure": {
    "error": "an error message",
    "details": "extended details ..."  // this may or may not be present, depending on the failure
  }
}

And the pebble checks CLI command is extended with a Last Failure field and a --verbose option as follows:

# In non-verbose mode (default), the "Last Failure" field and details are included
# on a single line, but truncated to 60 chars max (with "..." suffix if truncated)
$ pebble checks
Check  Level  Status  Failures  Last Failure
chk1   -      down    1/1       an error message: extended details ...

# In --verbose mode, the first line is the error message and subsequent lines show
# the details, if any
$ pebble checks --verbose
Check  Level  Status  Failures  Last Failure
chk1   -      down    1/1       an error message:
                                extended details ...
                                may be multiple lines ...

@@ -75,7 +75,7 @@ func (c *httpChecker) check(ctx context.Context) error {
details = strings.Join(lines, "\n")
}
return &detailsError{
error: fmt.Errorf("received non-20x status code %d", response.StatusCode),
error: fmt.Errorf("non-20x status code %d", response.StatusCode),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shortened this check error message slightly as "received" seemed redundant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually we call them 2xx 3xx 4xx etc when referring to http status codes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

@benhoyt benhoyt changed the title Add last failure (error and details) to checks API and CLI command Add last failure info to checks API and CLI command Aug 15, 2022
@benhoyt
Copy link
Contributor Author

benhoyt commented Sep 16, 2022

Per discussion at London mini-sprint, with the new approach of doing checks via changes and tasks properly, we likely don't need this. Though we could show error information pulled from the change/task in pebble checks.

@benhoyt
Copy link
Contributor Author

benhoyt commented Feb 14, 2023

Per above, we're planning to do this a different way via changes+tasks.

@benhoyt benhoyt closed this Feb 14, 2023
@benhoyt benhoyt deleted the last-failure branch March 13, 2023 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants