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 support for warnings that do not error endpoints #193

Merged
merged 3 commits into from
May 25, 2018
Merged

Conversation

codingjoe
Copy link
Collaborator

Add a new concept of warnings and non-critical services. Both
will not cause the template and JSON endpoint to response with a
500 status code but with a regular 200. This change is backwards
compatible because the existing warnings are treated as errors by
default.

Close #191

@codecov-io
Copy link

codecov-io commented May 24, 2018

Codecov Report

Merging #193 into master will increase coverage by 1.63%.
The diff coverage is 82.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #193      +/-   ##
==========================================
+ Coverage   73.92%   75.56%   +1.63%     
==========================================
  Files          28       29       +1     
  Lines         303      311       +8     
==========================================
+ Hits          224      235      +11     
+ Misses         79       76       -3
Impacted Files Coverage Δ
health_check/exceptions.py 100% <ø> (ø) ⬆️
health_check/contrib/psutil/backends.py 0% <0%> (ø) ⬆️
health_check/backends.py 100% <100%> (ø) ⬆️
health_check/views.py 100% <100%> (ø) ⬆️
health_check/conf.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c1179c...60e9cce. Read the comment docs.

Add a new concept of warnings and non-critical services. Both
will not cause the template and JSON endpoint to response with a
500 status code but with a regular 200. This change is backwards
compatible because the existing warnings are treated as errors by
default.

Close #191
@@ -23,14 +25,20 @@ def get(self, request, *args, **kwargs):
def _run(plugin):
plugin.run_check()
try:
return plugin.errors
return plugin.errors, plugin

Choose a reason for hiding this comment

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

Is there a reason we don't just return plugin here? Either way we're changing the method signature, but given it's declared within the scope of the view itself, no one else should be relying on it. Seems cleaner that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're absolutely right, thanks!

from health_check.exceptions import (
ServiceReturnedUnexpectedResult, ServiceWarning
)

host = socket.gethostname()

if hasattr(settings, 'HEALTH_CHECK'):

Choose a reason for hiding this comment

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

Much better, these were getting ugly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it has outlived it's design.

@codingjoe codingjoe merged commit ab17802 into master May 25, 2018
@codingjoe codingjoe deleted the warnings branch May 25, 2018 09:27
@codingjoe
Copy link
Collaborator Author

Released in 3.6.0

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.

3 participants