Skip to content
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

Feature: brownout deprecated API features via enable_brownout flag #1007

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading