You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2023/06/08 16:17:09 UTC

[GitHub] [superset] betodealmeida opened a new pull request, #24324: chore: rate limit requests

betodealmeida opened a new pull request, #24324:
URL: https://github.com/apache/superset/pull/24324

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   Rate limit the export dashboard endpoint.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] dpgaspar commented on a diff in pull request #24324: chore: rate limit requests

Posted by "dpgaspar (via GitHub)" <gi...@apache.org>.
dpgaspar commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1255498668


##########
superset/config.py:
##########
@@ -264,6 +264,12 @@ def _try_json_readsha(filepath: str, length: int) -> str | None:
 # Configuration for scheduling queries from SQL Lab.
 SCHEDULED_QUERIES: dict[str, Any] = {}
 
+# Rate limiting
+RATELIMIT_ENABLED = True
+AUTH_RATE_LIMITED = True
+AUTH_RATE_LIMIT = "2 per 5 second"
+RATELIMIT_APPLICATION = "50 per second"

Review Comment:
   it's done exactly like that



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida commented on a diff in pull request #24324: chore: rate limit requests

Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1255070060


##########
superset/models/dashboard.py:
##########
@@ -382,7 +382,7 @@ def export_dashboards(  # pylint: disable=too-many-locals
     ) -> str:
         copied_dashboards = []
         datasource_ids = set()
-        for dashboard_id in dashboard_ids:
+        for dashboard_id in set(dashboard_ids):

Review Comment:
   Good point, let me fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24324: chore: rate limit requests

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1224560484


##########
superset/models/dashboard.py:
##########
@@ -382,7 +382,7 @@ def export_dashboards(  # pylint: disable=too-many-locals
     ) -> str:
         copied_dashboards = []
         datasource_ids = set()
-        for dashboard_id in dashboard_ids:
+        for dashboard_id in set(dashboard_ids):

Review Comment:
   If there's an issue with duplicates—where order doesn't matter—is there merit in changing the `export_dashboards` method to have `dashboard_ids` as `set[int]`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] dpgaspar commented on a diff in pull request #24324: chore: rate limit requests

Posted by "dpgaspar (via GitHub)" <gi...@apache.org>.
dpgaspar commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1232143521


##########
superset/config.py:
##########
@@ -264,6 +264,12 @@ def _try_json_readsha(filepath: str, length: int) -> str | None:
 # Configuration for scheduling queries from SQL Lab.
 SCHEDULED_QUERIES: dict[str, Any] = {}
 
+# Rate limiting
+RATELIMIT_ENABLED = True
+AUTH_RATE_LIMITED = True
+AUTH_RATE_LIMIT = "2 per 5 second"
+RATELIMIT_APPLICATION = "50 per second"

Review Comment:
   Airflow implemented the same, their using `auth_rate_limit = 5 per 40 second`. Not sure about rate limiting the entire application this way, rate limits are better when tied to a user and state is set globally, this is possible with [flask-limiter](https://flask-limiter.readthedocs.io/en/stable/) (what FAB is using for this) but needs further configuration.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida commented on a diff in pull request #24324: chore: rate limit requests

Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1255069623


##########
superset/config.py:
##########
@@ -264,6 +264,12 @@ def _try_json_readsha(filepath: str, length: int) -> str | None:
 # Configuration for scheduling queries from SQL Lab.
 SCHEDULED_QUERIES: dict[str, Any] = {}
 
+# Rate limiting
+RATELIMIT_ENABLED = True
+AUTH_RATE_LIMITED = True
+AUTH_RATE_LIMIT = "2 per 5 second"
+RATELIMIT_APPLICATION = "50 per second"

Review Comment:
   Wait, I though these configuration keys would enable `flask-limiter` in FAB? That's not the case? How do we do that then?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida merged pull request #24324: chore: rate limit requests

Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida merged PR #24324:
URL: https://github.com/apache/superset/pull/24324


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24324: chore: rate limit requests

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1224561176


##########
superset/config.py:
##########
@@ -264,6 +264,12 @@ def _try_json_readsha(filepath: str, length: int) -> str | None:
 # Configuration for scheduling queries from SQL Lab.
 SCHEDULED_QUERIES: dict[str, Any] = {}
 
+# Rate limiting

Review Comment:
   ```suggestion
   # FAB rate limiting
   ```
   
   Maybe there's merit in mentioning FAB so it's clear where these limits are being enforced.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #24324: chore: rate limit requests

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #24324:
URL: https://github.com/apache/superset/pull/24324#issuecomment-1672390578

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#24324](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (91606e4) into [master](https://app.codecov.io/gh/apache/superset/commit/9c54280d8520f81a7928150194c4fb6c7b04e324?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (9c54280) will **decrease** coverage by `10.53%`.
   > The diff coverage is `50.00%`.
   
   > :exclamation: Current head 91606e4 differs from pull request most recent head ad89b83. Consider uploading reports for the commit ad89b83 to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #24324       +/-   ##
   ===========================================
   - Coverage   69.00%   58.48%   -10.53%     
   ===========================================
     Files        1906     1906               
     Lines       74149    74153        +4     
     Branches     8211     8211               
   ===========================================
   - Hits        51169    43365     -7804     
   - Misses      20856    28664     +7808     
     Partials     2124     2124               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `54.18% <50.00%> (+<0.01%)` | :arrow_up: |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `54.08% <50.00%> (+<0.01%)` | :arrow_up: |
   | python | `61.35% <50.00%> (-22.02%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `55.05% <50.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files Changed](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [superset/dashboards/api.py](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9hcGkucHk=) | `50.76% <0.00%> (-41.84%)` | :arrow_down: |
   | [superset/models/dashboard.py](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL2Rhc2hib2FyZC5weQ==) | `48.06% <ø> (-29.85%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/views/dashboard/views.py](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmlld3MvZGFzaGJvYXJkL3ZpZXdzLnB5) | `61.44% <0.00%> (-6.03%)` | :arrow_down: |
   | [superset/config.py](https://app.codecov.io/gh/apache/superset/pull/24324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29uZmlnLnB5) | `91.73% <100.00%> (-0.47%)` | :arrow_down: |
   
   ... and [289 files with indirect coverage changes](https://app.codecov.io/gh/apache/superset/pull/24324/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] betodealmeida commented on a diff in pull request #24324: chore: rate limit requests

Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on code in PR #24324:
URL: https://github.com/apache/superset/pull/24324#discussion_r1223282085


##########
superset/config.py:
##########
@@ -264,6 +264,12 @@ def _try_json_readsha(filepath: str, length: int) -> str | None:
 # Configuration for scheduling queries from SQL Lab.
 SCHEDULED_QUERIES: dict[str, Any] = {}
 
+# Rate limiting
+RATELIMIT_ENABLED = True
+AUTH_RATE_LIMITED = True
+AUTH_RATE_LIMIT = "2 per 5 second"
+RATELIMIT_APPLICATION = "50 per second"

Review Comment:
   @dpgaspar I know these were introduced in FAB 4.3.0. Do you have an idea of what sensible defaults would be for Superset?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org