-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
feat: allow admins to specify a timeout for MongoDB queries #8561
Conversation
Kudos, SonarCloud Quality Gate passed! |
Codecov Report
@@ Coverage Diff @@
## main #8561 +/- ##
=======================================
Coverage 48.73% 48.74%
=======================================
Files 114 114
Lines 21397 21406 +9
Branches 4786 4787 +1
=======================================
+ Hits 10428 10434 +6
- Misses 9685 9687 +2
- Partials 1284 1285 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@stephanegigandet if you have to change nginx, you can do it in the PR (see conf folder), even if at release time you have to copy it (on off1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool.
@@ -793,6 +793,8 @@ sub init_request ($request_ref = {}) { | |||
if (is_admin_user($User_id)) { | |||
$admin = 1; | |||
} | |||
$request_ref->{admin} = $admin; | |||
# TODO: remove the $admin global variable, and use $request_ref->{admin} instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
=head2 get_products_collection_request_parameters ($request_ref, $additional_parameters_ref = {} ) | ||
|
||
This function looks at the request object to set parameters to pass to the get_products_collection() function. | ||
|
||
=head3 Arguments | ||
|
||
=head4 $request_ref request object | ||
|
||
=head4 $additional_parameters_ref | ||
|
||
An optional reference to a hash of parameters that should be added to the parameters extracted from the request object. | ||
This is useful in particular to request the query to be executed on the smaller products_tags category, by passing | ||
{ tags = 1 } | ||
|
||
=head3 Return value | ||
|
||
A reference to a parameters object that can be passed to get_products_collection() | ||
|
||
=cut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like this kind of design.
This PR adds a &timeout=[number of ms] parameter that can be used by admins in order to override the default timeout (currently 50s in production), in order to be able to run queries that run longer. This could be useful for instance for monitoring queries (e.g. getting stats on recognized ingredients).
Note that the proxy timeout in nginx is currently not set (except on the pro platform where we can have big uploads), and the default is 60 sec. So in order for the timeout to have a real effect, we would also need to change the nginx config to include something like: