Skip to content

Commit

Permalink
Feature: brownout deprecated API features via enable_brownout flag
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Dec 12, 2024
1 parent 12d25f3 commit 882d0bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions mwdb/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class MWDBConfig(Config):
log_only_slow_sql = key(cast=intbool, required=False, default=False)
use_x_forwarded_for = key(cast=intbool, required=False, default=False)
enable_debug_log = key(cast=intbool, required=False, default=False)
enable_brownout = key(cast=intbool, required=False, default=False)


@section("karton")
Expand Down
10 changes: 10 additions & 0 deletions mwdb/core/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from typing import Optional

from flask import g, request
from werkzeug.exceptions import BadRequest

from mwdb.core.config import app_config
from mwdb.core.log import getLogger
from mwdb.core.metrics import metric_deprecated_usage

Expand Down Expand Up @@ -60,6 +62,14 @@ def uses_deprecated_api(
f"Used deprecated feature: {feature}"
+ (f" ({method} {endpoint})" if endpoint is not None else "")
)
if app_config.mwdb.enable_brownout:
if feature == DeprecatedFeature.legacy_api_key_v2:
# This feature won't be removed in v3
return
raise BadRequest(
f"Brownout: {feature} API feature is deprecated and currently disabled. "
f"Please upgrade your MWDB API client."
)


def deprecated_endpoint(feature: DeprecatedFeature):
Expand Down

0 comments on commit 882d0bf

Please sign in to comment.