Skip to content

Commit 90dd977

Browse files
Add redis cluster config (#5799)
# Support Redis Cluster We are using a redis cluster setup, but the current code uses redis.from_url which only works for Redis Standalone. See: https://github.com/redis/redis-py/blob/ceb12fe8b52f488bd1e0a42b9dc53161e77514d0/redis/utils.py#L33 So I added a config-option to support Redis Cluster which should not break the current default behavior only extend it. **Type of change** - New feature (non-breaking change which adds functionality) - Documentation update **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> AWS Redis cluster deployment **Checklist** - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - TODO - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: David Berenstein <[email protected]>
1 parent 9bc5f10 commit 90dd977

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

argilla-server/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ These are the section headers that we use:
1616

1717
## [Unreleased]()
1818

19+
## Added
20+
21+
- Add configuration switch to use Redis cluster vs Redis standalone via ARGILLA_REDIS_USE_CLUSTER ([#5799](https://github.com/argilla-io/argilla/pull/5799))
22+
1923
### Fixed
2024

2125
- Fixed error when computing user progress with PostgreSQL database. ([#5795](https://github.com/argilla-io/argilla/pull/5795))

argilla-server/src/argilla_server/jobs/queues.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
# limitations under the License.
1414

1515
import redis
16+
from redis.cluster import RedisCluster
1617

1718
from rq import Queue
1819

1920
from argilla_server.settings import settings
2021

21-
REDIS_CONNECTION = redis.from_url(settings.redis_url)
22+
if settings.redis_use_cluster:
23+
REDIS_CONNECTION = RedisCluster.from_url(settings.redis_url)
24+
else:
25+
REDIS_CONNECTION = redis.from_url(settings.redis_url)
2226

2327
DEFAULT_QUEUE = Queue("default", connection=REDIS_CONNECTION)
2428
HIGH_QUEUE = Queue("high", connection=REDIS_CONNECTION)

argilla-server/src/argilla_server/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class Settings(BaseSettings):
114114
cors_origins: List[str] = ["*"]
115115

116116
redis_url: str = "redis://localhost:6379/0"
117+
redis_use_cluster: bool = False
117118

118119
docs_enabled: bool = True
119120

argilla/docs/reference/argilla-server/configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ The following environment variables are useful only when PostgreSQL is used:
9696
Redis is used by Argilla to store information about jobs to be processed on background. The following environment variables are useful to config how Argilla connects to Redis:
9797

9898
- `ARGILLA_REDIS_URL`: A URL string that contains the necessary information to connect to a Redis instance (Default: `redis://localhost:6379/0`).
99+
- `ARGILLA_REDIS_USE_CLUSTER`: If "True" tries the connection with the URL to a Redis Cluster instead of a Redis Standalone instance.
99100

100101
### Datasets
101102

examples/deployments/k8s/argilla-chart/templates/deployment.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ spec:
3737
- name: ARGILLA_AUTH_SECRET_KEY
3838
value: {{ .Values.argilla.authSecretKey | quote }}
3939
- name: ARGILLA_REDIS_URL
40-
value: redis://{{ .Release.Name }}-redis-master:6379/0
40+
value: {{if .Values.externalRedis.enabled}}"{{ .Values.externalRedis.url }}"{{else}}"redis://{{ .Release.Name }}-redis-master:6379/0"{{end}}
41+
- name: ARGILLA_REDIS_USE_CLUSTER
42+
value: {{ if and .Values.externalRedis.enabled .Values.externalRedis.is_redis_cluster }} "True" {{ else }} "False" {{ end }}
4143
- name: USERNAME
4244
value: {{ .Values.argilla.auth.username | quote }}
4345
- name: PASSWORD

examples/deployments/k8s/argilla-chart/values.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ redis:
8080
limits:
8181
cpu: 1
8282
memory: 2Gi
83+
84+
externalRedis:
85+
enabled: false
86+
url: "redis://localhost:6379/0"
87+
is_redis_cluster: false
88+
8389
serviceAccount:
8490
create: false
8591

0 commit comments

Comments
 (0)