Commit a1dc56c
committed
feat(cache): add Redis Cluster support for HA deployments
Implements Redis Cluster client support in slurm-web agent to enable
high-availability caching across distributed Redis clusters.
## Problem
Slurm-web currently supports only standalone Redis instances for caching.
In high-availability deployments with Redis Cluster (3+ node clustered Redis),
slurm-web agents fail to connect because they use the standard redis.Redis()
client instead of the cluster-aware redis.cluster.RedisCluster() client.
## Solution
This commit adds optional Redis Cluster support while maintaining full
backwards compatibility with standalone Redis deployments.
### Core Changes
**slurmweb/cache.py**:
- Import RedisCluster and ClusterNode from redis.cluster
- Add cluster_mode and cluster_nodes optional parameters to CachingService
- Implement cluster mode initialization with RedisCluster client
- Parse cluster_nodes from "host:port" string format
- Add connection validation with fail-fast error handling
**slurmweb/apps/agent.py**:
- Pass cluster_mode and cluster_nodes parameters to CachingService
- Use getattr() with defaults for backwards compatibility
**conf/vendor/agent.yml**:
- Add cluster_mode boolean parameter (default: false)
- Add cluster_nodes list parameter with string content type
- Document configuration with examples
## Features
- **Opt-in design**: Cluster mode disabled by default (cluster_mode=false)
- **Automatic failover**: Cluster continues if a Redis node fails
- **Load distribution**: Requests distributed across cluster nodes
- **Backwards compatible**: Existing standalone configurations work unchanged
- **Fail-fast validation**: Connection tested at initialization
## Configuration Example
```ini
[cache]
enabled = yes
cluster_mode = yes
cluster_nodes =
10.0.0.1:6379
10.0.0.2:6379
10.0.0.3:6379
jobs = 30
nodes = 30
```
## Testing
Tested on production environment:
- Slurm-web 6.0.0
- Redis cluster: 3 nodes
- Slurm controllers: 2 nodes
- OS: Ubuntu 24.04
- Verified backward compatibility with standalone mode
## Implementation Notes
- Uses "host:port" string format for RFL schema compatibility (list content type must be str, not dict)
- skip_full_coverage_check=True allows partial cluster visibility
- decode_responses=False maintains pickle serialization compatibility
- Connection validated with ping() at initialization
Closes: #[issue-number]1 parent f628349 commit a1dc56c
3 files changed
+79
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
461 | 481 | | |
462 | 482 | | |
463 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
35 | 54 | | |
36 | 55 | | |
37 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
38 | 93 | | |
39 | 94 | | |
40 | 95 | | |
| |||
0 commit comments