Skip to content

Commit

Permalink
chore: remove flask limiter
Browse files Browse the repository at this point in the history
pin connexion to ~=3.1.0 because of spec-first/connexion#2029
RHINENG-14559
  • Loading branch information
psegedy committed Feb 12, 2025
1 parent 0233985 commit 833d54e
Show file tree
Hide file tree
Showing 3 changed files with 438 additions and 591 deletions.
13 changes: 0 additions & 13 deletions manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@

import connexion
from a2wsgi import ASGIMiddleware
from connexion import context
from connexion.options import SwaggerUIOptions
from connexion.resolver import RestyResolver
from flask import abort
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
from peewee import OperationalError
from prometheus_client import CollectorRegistry
from prometheus_client import generate_latest
Expand Down Expand Up @@ -60,8 +57,6 @@ def create_app(spec_files, wait_on_cyndi=True, init_status_cache=True):
app.add_error_handler(MissingEntitlementException, forbidden_missing_entitlement)
app.add_error_handler(RbacException, forbidden_rbac)

limiter = Limiter(app=app.app, key_func=get_remote_address)

@app.app.after_request
def set_default_headers(response): # pylint: disable=unused-variable
response.headers["Access-Control-Allow-Origin"] = "*"
Expand All @@ -78,14 +73,6 @@ def set_default_headers(response): # pylint: disable=unused-variable

return response

# Apply global throttling for all routes
@app.app.before_request
@limiter.limit(f"{CFG.api_max_rps} per second",
key_func=lambda: context.request.headers.get("x-rh-identity"),
exempt_when=lambda: context.request.headers.get("x-rh-identity") is None) # workaround for limiter errors
def account_level_throttle():
return

# This hook ensures that a connection is opened to handle any queries
# generated by the request.
@app.app.before_request
Expand Down
Loading

0 comments on commit 833d54e

Please sign in to comment.