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

ref: remove python-memcache #63375

Merged
merged 1 commit into from
Jan 18, 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
2 changes: 0 additions & 2 deletions requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ PyJWT>=2.4.0
pydantic>=1.10.9
python-dateutil>=2.8.2
pymemcache
# TODO: once pymemcache is validated, remove python-memcached
python-memcached>=1.59
python-u2flib-server>=5.0.0
fido2>=0.9.2
python3-saml>=1.15.0
Expand Down
1 change: 0 additions & 1 deletion requirements-dev-frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ pytest-rerunfailures==11.0
pytest-sentry==0.1.11
pytest-xdist==3.0.2
python-dateutil==2.8.2
python-memcached==1.59
python-rapidjson==1.8
python-u2flib-server==5.0.0
python-utils==3.3.3
Expand Down
1 change: 0 additions & 1 deletion requirements-frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ pyjwt==2.4.0
pymemcache==4.0.0
pyparsing==3.0.9
python-dateutil==2.8.2
python-memcached==1.59
python-rapidjson==1.8
python-u2flib-server==5.0.0
python-utils==3.3.3
Expand Down
2 changes: 1 addition & 1 deletion self-hosted/sentry.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
memcached_port = env("SENTRY_MEMCACHED_PORT") or "11211"
CACHES = {
"default": {
"BACKEND": "sentry.utils.memcached.MemcachedCache",
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": [memcached + ":" + memcached_port],
"TIMEOUT": 3600,
}
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/data/config/sentry.conf.py.default
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DEBUG = %(debug_flag)s
#
# CACHES = {
# 'default': {
# 'BACKEND': 'sentry.utils.memcached.MemcachedCache',
# 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
# 'LOCATION': ['127.0.0.1:11211'],
# }
# }
Expand Down
11 changes: 0 additions & 11 deletions src/sentry/services/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,13 @@ def __init__(
port: int | None = None,
debug: bool = False,
workers: int | None = None,
validate: bool = True,
extra_options: dict[str, Any] | None = None,
) -> None:
from django.conf import settings

from sentry import options as sentry_options
from sentry.logging import LoggingFormat

if validate:
self.validate_settings()

host = host or settings.SENTRY_WEB_HOST
port = port or settings.SENTRY_WEB_PORT

Expand Down Expand Up @@ -146,13 +142,6 @@ def __init__(
self.options = options
self.debug = debug

def validate_settings(self) -> None:
from django.conf import settings as django_settings

from sentry.utils.settings import validate_settings

validate_settings(django_settings)

def prepare_environment(self, env: MutableMapping[str, str] | None = None) -> None:
from django.conf import settings

Expand Down
69 changes: 0 additions & 69 deletions src/sentry/utils/memcached.py

This file was deleted.

46 changes: 0 additions & 46 deletions src/sentry/utils/settings.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,3 @@
from sentry.utils.imports import import_string

PACKAGES = {
"django.db.backends.postgresql_psycopg2": "psycopg2.extensions",
"sentry.db.postgres": "psycopg2.extensions",
"sentry.utils.memcached.MemcachedCache": "memcache",
"django.core.cache.backends.memcached.PyLibMCCache": "pylibmc",
}


def validate_settings(settings):
for key, engine_key, engine_type in [
("DATABASES", "ENGINE", "database engine"),
("CACHES", "BACKEND", "caching backend"),
]:

value = getattr(settings, key, {})
for alias in value:
engine = value[alias][engine_key]
if engine not in PACKAGES:
continue
validate_dependency(settings, engine_type, engine, PACKAGES[engine])


def validate_dependency(settings, dependency_type, dependency, package):
try:
import_string(package)
except ImportError as e:
msg = ConfigurationError.get_error_message(f"{dependency_type} {dependency}", package)
raise ConfigurationError(msg).with_traceback(e.__traceback__)


class ConfigurationError(ValueError):
"""
This error is thrown whenever a sentry configuration is wrong, or requires a third-party library
that's not installed properly or can't be found.
"""

@classmethod
def get_error_message(cls, dependency, package):
return (
"""Python could not find %(package)s in your current environment (required by %(dependency)s). If you have it installed, maybe you are using the wrong python binary to run sentry?"""
% {"dependency": dependency, "package": package}
)


def is_self_hosted() -> bool:
# Backcompat for rename to support old consumers, particularly single-tenant.
from django.conf import settings
Expand Down
86 changes: 0 additions & 86 deletions tests/sentry/utils/test_settings.py

This file was deleted.

Loading