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

Stop logging proxied 5XX Graphite errors #3260

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lunkwill42
Copy link
Member

@lunkwill42 lunkwill42 commented Dec 20, 2024

This adds what amounts to a dirty hack to the graphite-web proxy view (i.e. it reaches into Django internals) to prevent Django from doing a full error response log when proxying 5xx class errors from graphite-web. It does so by tricking django.utils.log.log_response() into thinking that the response has already been logged (since our view function has no other control over how its return values are logged by Django).

The reason for the 5xx response codes are not bugs in our view code, and does not need to trigger site admin e-mails.

Adds regression tests and fixes #3259

@lunkwill42 lunkwill42 self-assigned this Dec 20, 2024
Copy link

github-actions bot commented Dec 20, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 2 0 0.62s
✅ PYTHON ruff 2 0 0.01s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

github-actions bot commented Dec 20, 2024

Test results

    9 files      9 suites   8m 11s ⏱️
2 165 tests 2 165 ✅ 0 💤 0 ❌
4 069 runs  4 069 ✅ 0 💤 0 ❌

Results for commit 20aa215.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.64%. Comparing base (35b0f71) to head (20aa215).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3260      +/-   ##
==========================================
+ Coverage   60.58%   60.64%   +0.06%     
==========================================
  Files         606      606              
  Lines       43733    43735       +2     
  Branches       48       48              
==========================================
+ Hits        26494    26522      +28     
+ Misses      17227    17201      -26     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This adds a bit of complicated regression testing of #3259, which
causes Dango to send error e-mail to NAV site admins when the proxied
response code from Graphite-web is in the 5XX range.
This adds what amounts to a dirty hack to the graphite-web proxy
view (i.e. it reaches into Django internals) to prevent Django from
doing a full error response log when proxying 5xx class errors from
graphite-web.  It does so by tricking `django.utils.log.log_response()`
into thinking that the response has already been logged (since our
view function has no other control over how its return values are
logged by Django).

The reason for the 5xx response codes are not bugs in our view code,
and does not need to trigger site admin e-mails.
@lunkwill42 lunkwill42 force-pushed the bugfix/no-django-email-on-graphite-web-errors branch from f847310 to 20aa215 Compare December 20, 2024 15:47
@lunkwill42 lunkwill42 marked this pull request as ready for review December 20, 2024 15:47
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.

[BUG] Django error e-mail is sent to site admins when Graphite is not responding properly
2 participants