redis_sentinel: Add SSL/TLS, username/ACL, and Redis 7+ replica support - #3071
Open
ian28223 wants to merge 5 commits into
Open
redis_sentinel: Add SSL/TLS, username/ACL, and Redis 7+ replica support#3071ian28223 wants to merge 5 commits into
ian28223 wants to merge 5 commits into
Conversation
Recreates #2939 (closed for inactivity) with CI failures fixed: ruff/black formatting via `ddev test --fmt`, and the `redis` dependency pinned exactly (redis==7.3.0) and synced with `ddev dep freeze`, since `ddev validate dep` rejects unstable `>=` pins. Fixes #2938, #2395, #1586 Co-Authored-By: Arnold Mendez <amendez-primer@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
🎯 Code Coverage (details) 🔗 Commit SHA: f8c911b | Docs | Datadog PR Page | Give us feedback! |
datadog-checks-base==4.2.0 (the previous floor) imports `from six.moves.urllib.parse import urlparse` in utils/common.py, but `six` is only declared under its `deps` extra, not as an unconditional dependency. The "minimum base package" CI job installs the bare package, so importing datadog_checks.base fails with `ModuleNotFoundError: No module named 'six.moves'`. This reproduces identically on current master, unrelated to the SSL/ ACL changes in this PR. six.moves usage was removed upstream starting in datadog-checks-base 37.2ish (confirmed 37.1.0 still imports six, 37.3.0 no longer does), so bumping the floor to 37.3.0 fixes it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
37.3.0's [deps] extra pins ddtrace==2.10.6, which has no prebuilt wheel for cp313. The minimum-base-package CI job's build environment lacks pkg_resources for legacy setuptools-based source builds, so installing datadog-checks-base[deps]==37.3.0 fails trying to compile ddtrace from source: ModuleNotFoundError: No module named 'pkg_resources' datadog-checks-base 37.10.0 bumps its ddtrace pin to 2.21.4, which ships a cp313 wheel (confirmed via `pip download --only-binary`), avoiding the source build entirely. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ian28223
marked this pull request as ready for review
July 24, 2026 01:19
HadhemiDD
requested changes
Jul 30, 2026
- Add ssl_check_hostname passthrough. redis-py defaults this to True
and only auto-disables it when ssl_cert_reqs == CERT_NONE, so a
sentinel reached by IP with a hostname-mismatched cert previously
had no escape short of disabling certificate verification entirely
via ssl_cert_reqs: 0. Matches redisdb's existing ssl_check_hostname
option.
- Drop the _get_sentinel_replicas() helper and its "Redis 7+
REPLICAS" claim. redis-py's StrictRedis has no sentinel_replicas
method in any released version (confirmed against 7.3.0's
commands/sentinel.py), so hasattr() was always False and the
fallback to sentinel_slaves() ran unconditionally - identical
behavior to master, just with dead code and an inaccurate PR
description. Restored the direct sentinel_slaves() call and the
corresponding mock.patch('redis.StrictRedis.sentinel_slaves', ...)
in test_down_slaves so the real code path is exercised again.
- Bump to 1.2.0 and add a CHANGELOG entry, since extras uses a
hand-written CHANGELOG.md with no towncrier fragments and this
otherwise can't ship.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
|
Thanks for the thorough review — I verified all four points against redis-py 7.3.0 source directly and they all held up:
Pushed in f8c911b. Lint and unit tests pass locally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modernizes the Redis Sentinel check to support TLS-enabled deployments and Redis 6+ ACLs.
Supersedes #2939 (opened by @amendez-primer, auto-closed for inactivity after CI kept failing). Same change set, with the CI failures fixed and review feedback addressed:
ddev test --fmt redis_sentinelwith the current ddev version, which the original review asked for but the PR never got an updated pass on.ddev validate deprejects unstable>=pins. Theredisdependency is now pinned exactly (redis==7.3.0, matchingredisdbinintegrations-core) instead ofredis>=4.5.0.datadog-checks-basefrom>=4.2.0to>=37.10.0. The old floor importssix.moves, which isn't declared as a hard dependency, and its[deps]extra pins an oldddtracewith nocp313wheel — both broke the "minimum base package" CI job on unmodifiedmastertoo, unrelated to this PR's changes._get_sentinel_replicas()removed: a reviewer caught thatredis.StrictRedisnever had asentinel_replicasmethod in any released version, so thehasattr()check was alwaysFalseand this always fell through tosentinel_slaves()— dead code with an inaccurate description (see below).ssl_check_hostnameadded: a reviewer caught that redis-py defaults hostname verification toTrueand only disables it whenssl_cert_reqsisCERT_NONE, so a sentinel reached by IP with a hostname-mismatched cert had no escape short of disabling certificate verification entirely. Matchesredisdb's existing option.Fixes #2938, #2395
Changes
1. SSL/TLS support (#2938)
The check previously created
redis.StrictRedisconnections without any SSL parameters, making it impossible to connect to TLS-enabled Sentinel instances (e.g. AWS ElastiCache, Azure Cache for Redis).Added support for:
ssl,ssl_certfile,ssl_keyfile,ssl_ca_certs,ssl_cert_reqs,ssl_check_hostname— matching the coreredisdbintegration.2. Username / ACL support (#2395)
Redis 6+ introduced ACLs requiring a
usernameparameter. Without it,AUTHfails with:AUTH <password> called without any password configured for the default user.Added
sentinel_usernameinstance config option, passed through toStrictRedis(username=...).3. Socket timeout
Added
socket_timeoutconfig option (default: 5s) to prevent the check from hanging indefinitely on unreachable sentinels.Note: an earlier revision of this PR also claimed a Redis 7+
SENTINEL REPLICASfallback (#1586). That code path was dead (see above) and the underlying premise didn't hold up either —SENTINEL SLAVESis still a live alias forSENTINEL REPLICASin current Redis, not a removed subcommand — so it's been dropped rather than reimplemented.Files changed
redis_sentinel.py_load_config()conf.yaml.exampletest_redis_sentinel.pypyproject.tomlredisdep to==7.3.0(pinned, matchesredisdb); bumpeddatadog-checks-basefloor to>=37.10.0__about__.py/CHANGELOG.mdBackward compatibility
ssl: true, behavior is identical to beforeTest plan
ddev test --lint redis_sentinelpasses (ruff format + check)ddev test redis_sentinel -- -m unitpasses (4/4 unit tests)ddev test redis_sentinel) — pass locally except for an arm64/amd64 emulation issue with theerichsu/redis-sentineltest image unrelated to this change; CI runs on amd64 and is green🤖 Generated with Claude Code