diff --git a/docs/installation/2-redis.md b/docs/installation/2-redis.md index 00a02b889..f412cced1 100644 --- a/docs/installation/2-redis.md +++ b/docs/installation/2-redis.md @@ -8,7 +8,10 @@ sudo apt install -y redis-server ``` -Before continuing, verify that your installed version of Redis is at least v5.0: +Before continuing, verify that your installed version of Redis is at least v6.0: + +!!! warning "Redis v5.x is deprecated" + Support for Redis versions older than 6.0 is deprecated and will be removed in NetBox v4.7. ```no-highlight redis-server -v diff --git a/docs/installation/index.md b/docs/installation/index.md index a20bcd369..38f5b1d76 100644 --- a/docs/installation/index.md +++ b/docs/installation/index.md @@ -29,9 +29,10 @@ The following sections detail how to set up a new instance of NetBox: |------------|--------------------| | Python | 3.12, 3.13, 3.14 | | PostgreSQL | 14+ [^1] | -| Redis | 5.0+ | +| Redis | 5.0+ [^2] | [^1]: Support for PostgreSQL 14 is deprecated and will be removed in NetBox v4.7. PostgreSQL 15 or later will be required. +[^2]: Support for Redis versions older than 6.0 is deprecated and will be removed in NetBox v4.7. Redis 6.0 or later will be required. Below is a simplified overview of the NetBox application stack for reference: diff --git a/netbox/core/apps.py b/netbox/core/apps.py index 86ed763b5..27f457607 100644 --- a/netbox/core/apps.py +++ b/netbox/core/apps.py @@ -22,7 +22,7 @@ class CoreConfig(AppConfig): def ready(self): from core.api import schema # noqa: F401 - from core.checks import check_duplicate_indexes, check_postgresql_version # noqa: F401 + from core.checks import check_duplicate_indexes, check_postgresql_version, check_redis_version # noqa: F401 from netbox import context_managers # noqa: F401 from netbox.models.features import register_models diff --git a/netbox/core/checks.py b/netbox/core/checks.py index 90300bdd3..d452641c7 100644 --- a/netbox/core/checks.py +++ b/netbox/core/checks.py @@ -1,4 +1,5 @@ from django.apps import apps +from django.core.cache import cache from django.core.checks import Error, Tags, Warning, register from django.db import connection from django.db.models import Index, UniqueConstraint @@ -6,6 +7,7 @@ from django.db.models import Index, UniqueConstraint __all__ = ( 'check_duplicate_indexes', 'check_postgresql_version', + 'check_redis_version', ) @@ -67,3 +69,27 @@ def check_postgresql_version(app_configs, **kwargs): except Exception: pass return warnings + + +@register(Tags.caches) +def check_redis_version(app_configs, **kwargs): + """ + Warn if the Redis version is less than 6.0, as support for Redis older than 6.0 + will be removed in NetBox v4.7. + """ + warnings = [] + try: + client = cache.client.get_client() + redis_version = tuple(int(x) for x in client.info()['redis_version'].split('.')) + if redis_version < (6, 0): + warnings.append( + Warning( + f'Support for Redis {".".join(str(x) for x in redis_version)} is deprecated and will be ' + f'removed in NetBox v4.7.', + hint='Please upgrade to Redis 6.0 or later.', + id='netbox.W002', + ) + ) + except Exception: + pass + return warnings