-
Notifications
You must be signed in to change notification settings - Fork 50
Fix various commands to work with Redis Cluster #338
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates RedisVL to support Redis Cluster deployments by adding cluster‐aware connection logic, refining client type hints and conversions, and updating tests and Docker Compose configurations for integration testing.
- Updated client connection factory functions and union types to support both sync and async Redis Cluster clients.
- Enhanced index, aggregation, cache, and router modules to correctly route commands in cluster mode.
- Modified tests and Docker configurations to validate and support Redis Cluster behavior.
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
tests/integration/* | Updated tests to use new client parameters and validate cluster support. |
tests/conftest.py & tests/cluster-compose.yml | Introduced fixtures and a Docker Compose file for Redis Cluster setup. |
redisvl/types.py | Added union types for cluster and async clients. |
redisvl/redis/connection.py | Refactored connection logic to automatically detect cluster URLs and create appropriate clients. |
redisvl/redis/utils.py | Introduced cluster_create_index and cluster_search functions for cluster compatibility. |
redisvl/index/* | Modified storage and search index implementations to support cluster commands. |
redisvl/extensions/* | Adjusted cache and router modules for consistent Redis Cluster client usage. |
pyproject.toml | Upgraded the redis package dependency and added new type dependency. |
- sh | ||
- -c | ||
- | | ||
echo "Waiting for Redis nodes to be available..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little much, but it was the result of many iterations on cluster startup failures. I may simplify!
tests/conftest.py
Outdated
) | ||
yield | ||
except subprocess.CalledProcessError as e: | ||
# Attempt to get logs if setup failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, multiple iterations on repeated startup failure 😬
@pytest.fixture(scope="session") | ||
def redis_cluster_url(redis_cluster_container): | ||
# Hard-coded due to Docker issues | ||
return "redis://localhost:7001" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently hard-coded due to issues obtaining the IP at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge effort!!
Description
This PR introduces Redis Cluster support throughout the library by updating internal client abstractions and connection logic. It ensures compatibility with both standalone and clustered Redis deployments.
Key Changes
Redis client compatibility
redis
from5.2.1
→6.1.0
, keeping backwards-compatible support for 5.x seriesredis.Redis
/redis.asyncio.Redis
types with union types (SyncRedisClient
,AsyncRedisClient
, etc.) inredisvl.types
Indexing improvements
FT.CREATE
,FT.SEARCH
, andFT.DROPINDEX
(supposed to be supported, but redis-py 6.1 still isn't sending these to the default node...)cluster_create_index
andcluster_search
utility functions to help fill these client gapsConnection handling
RedisConnectionFactory
to detect and create cluster clients automaticallyTest infrastructure
tests/cluster-compose.yml
)redis_cluster_url
,cluster_client
test_redis_cluster_support.py
)Other updates
tests/data
to.gitignore
types-redis
because its outdated type annotations cause erroneous lint errorsGotchas
--run-cluster-tests
.Why
Supporting Redis Cluster enables RedisVL to operate in high-availability, horizontally-scalable environments, making it production-ready for distributed Redis deployments.
This also unblocks us from allowing downstream libraries, such as langgraph-redis, to support Redis Cluster.
Breaking Changes
types-redis
(not compatible with updatedredis
package)