-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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(thumbnail cache): Enabling force parameter on screenshot/thumbnail cache #31757
base: master
Are you sure you want to change the base?
Conversation
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment
|
f05f59a
to
5ac969c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #31757 +/- ##
===========================================
+ Coverage 60.48% 83.55% +23.06%
===========================================
Files 1931 540 -1391
Lines 76236 39205 -37031
Branches 8568 0 -8568
===========================================
- Hits 46114 32756 -13358
+ Misses 28017 6449 -21568
+ Partials 2105 0 -2105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Korbit doesn't automatically review large (500+ lines changed) pull requests such as this one. If you want me to review anyway, use |
adding CacheScreenshotPayload state machine
22f419d
to
3112c16
Compare
SUMMARY
Both the
/api/v1/chart/{{id}}/cache_screenshot/
and/api/v1/dashboard/{{id}}/cache_dashboard_screenshot/
endpoints enable generating and retrieve a screenshot from the respective resource.The endpoints accept sending force=true in the query parameters, but currently this parameter does nothing. It should instead invalidate the previous image and generate a new one.
This PR introduces a fix as well as some improvements to the functioning of the thumbnail cache, such that the status of the screenshot can be tracked by the relevant api endpoints as well.
Rather than storing plain bytes objects in the cache, this PR introduces a new class
ScreenshotCachePayoad
which can store the image bytes as well astimestamp
andstatus
values. Status values includePending
: screenshot is awaiting being processedComputing
: screenshot job has been picked up by the worker and is processingUpdated
: screenshot has been updatedError
: an error occured while the webdriver was processing the screenshot task.While in a
Computing
orUpdated
state, requests to regenerate the screenshot will be blocked unless theforce
parameter is set toTrue
Additional
update_status
andupdated_at
fields have been added to 202 response payload for endpoints as follows:How to reproduce the bug
Create a chart.
Perform a modification in the data.
Send a GET request to /api/v1/chart/{{id}}/cache_screenshot/?q=(force:!t).
Access the URL returned in the image_url value.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
tests have been added in the
tests/unit_tests/utils/screenshot_tests.py
For manual testing
/api/v1/chart/<pk>/cache_screenshot/
endpoint. Ensure that a 202 response is received./api/v1/chart/cache_screenshot/<pk>/?q=(force:!t)
to ensure that the status changes to "Pending"Repeat the steps for the
POST /api/v1/dashboard/<pk>/cache_dashboard_screenshot/
GET /api/v1/chart/<pk>/thumbnail/<digest>
endpoint to ensure that a 202 response is received.GET /api/v1/dashboard/<pk>/thumbnail/<digest>
ADDITIONAL INFORMATION