Skip to content

Commit 5c49231

Browse files
ROCSP: Remove support for Redis Cluster (#6645)
Fixes #6517
1 parent 6792739 commit 5c49231

18 files changed

+51
-582
lines changed

cmd/rocsp-tool/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
type client struct {
23-
redis rocsp.Writer
23+
redis *rocsp.RWClient
2424
db *db.WrappedMap // optional
2525
ocspGenerator capb.OCSPGeneratorClient
2626
clk clock.Clock

cmd/rocsp-tool/client_test.go

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"math/big"
7-
"os"
87
"testing"
98
"time"
109

@@ -39,8 +38,8 @@ func makeClient() (*rocsp.RWClient, clock.Clock) {
3938

4039
rdb := redis.NewRing(&redis.RingOptions{
4140
Addrs: map[string]string{
42-
"shard1": "10.33.33.8:4218",
43-
"shard2": "10.33.33.9:4218",
41+
"shard1": "10.33.33.2:4218",
42+
"shard2": "10.33.33.3:4218",
4443
},
4544
Username: "unittest-rw",
4645
Password: "824968fa490f4ecec1e52d5e34916bdb60d45f8d",
@@ -50,32 +49,6 @@ func makeClient() (*rocsp.RWClient, clock.Clock) {
5049
return rocsp.NewWritingClient(rdb, 500*time.Millisecond, clk, metrics.NoopRegisterer), clk
5150
}
5251

53-
// TODO(#6517) remove this helper.
54-
func makeClusterClient() (*rocsp.CRWClient, clock.Clock) {
55-
CACertFile := "../../test/redis-tls/minica.pem"
56-
CertFile := "../../test/redis-tls/boulder/cert.pem"
57-
KeyFile := "../../test/redis-tls/boulder/key.pem"
58-
tlsConfig := cmd.TLSConfig{
59-
CACertFile: &CACertFile,
60-
CertFile: &CertFile,
61-
KeyFile: &KeyFile,
62-
}
63-
tlsConfig2, err := tlsConfig.Load()
64-
if err != nil {
65-
panic(err)
66-
}
67-
68-
rdb := redis.NewClusterClient(&redis.ClusterOptions{
69-
Addrs: []string{"10.33.33.2:4218"},
70-
Username: "unittest-rw",
71-
Password: "824968fa490f4ecec1e52d5e34916bdb60d45f8d",
72-
TLSConfig: tlsConfig2,
73-
})
74-
clk := clock.NewFake()
75-
76-
return rocsp.NewClusterWritingClient(rdb, 5*time.Second, clk, metrics.NoopRegisterer), clk
77-
}
78-
7952
func TestGetStartingID(t *testing.T) {
8053
clk := clock.NewFake()
8154
dbMap, err := sa.NewDbMap(vars.DBConnSAFullPerms, sa.DbSettings{})
@@ -109,14 +82,7 @@ func TestGetStartingID(t *testing.T) {
10982
}
11083

11184
func TestStoreResponse(t *testing.T) {
112-
// TODO(#6517) remove this block.
113-
var redisClient rocsp.Writer
114-
var clk clock.Clock
115-
if os.Getenv("BOULDER_CONFIG_DIR") == "test/config" {
116-
redisClient, clk = makeClusterClient()
117-
} else {
118-
redisClient, clk = makeClient()
119-
}
85+
redisClient, clk := makeClient()
12086

12187
issuer, err := core.LoadCert("../../test/hierarchy/int-e1.cert.pem")
12288
test.AssertNotError(t, err, "loading int-e1")
@@ -153,14 +119,7 @@ func (mog mockOCSPGenerator) GenerateOCSP(ctx context.Context, in *capb.Generate
153119
}
154120

155121
func TestLoadFromDB(t *testing.T) {
156-
// TODO(#6517) remove this block.
157-
var redisClient rocsp.Writer
158-
var clk clock.Clock
159-
if os.Getenv("BOULDER_CONFIG_DIR") == "test/config" {
160-
redisClient, clk = makeClusterClient()
161-
} else {
162-
redisClient, clk = makeClient()
163-
}
122+
redisClient, clk := makeClient()
164123

165124
dbMap, err := sa.NewDbMap(vars.DBConnSA, sa.DbSettings{})
166125
if err != nil {

docker-compose.next.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,3 @@ services:
55
FAKE_DNS: 10.77.77.77
66
BOULDER_CONFIG_DIR: &boulder_config_dir test/config-next
77
GOFLAGS: -mod=vendor
8-
# TODO(#6517): remove bredis_clusterer
9-
bredis_clusterer:
10-
depends_on:
11-
- bredis_7
12-
- bredis_8
13-
# TODO(#6517): move both nodes to docker-compose.yml
14-
bredis_7:
15-
image: redis:6.2.7
16-
volumes:
17-
- ./test/:/test/:cached
18-
command: redis-server /test/redis.config
19-
networks:
20-
redisnet:
21-
ipv4_address: 10.33.33.8
22-
23-
bredis_8:
24-
image: redis:6.2.7
25-
volumes:
26-
- ./test/:/test/:cached
27-
command: redis-server /test/redis.config
28-
networks:
29-
redisnet:
30-
ipv4_address: 10.33.33.9

docker-compose.yml

Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ services:
4141
- 4003:4003 # OCSP
4242
depends_on:
4343
- bmysql
44-
- bredis_clusterer
44+
- bredis_1
45+
- bredis_2
4546
- bconsul
4647
entrypoint: test/entrypoint.sh
4748
working_dir: &boulder_working_dir /boulder
@@ -62,13 +63,12 @@ services:
6263
command: mysqld --bind-address=0.0.0.0 --slow-query-log --log-output=TABLE --log-queries-not-using-indexes=ON
6364
logging:
6465
driver: none
65-
# TODO(#6517): replace all bredis_ services with those from
66-
# docker-compose.next.yml.
66+
6767
bredis_1:
6868
image: redis:6.2.7
6969
volumes:
7070
- ./test/:/test/:cached
71-
command: redis-server /test/redis-cluster.config
71+
command: redis-server /test/redis.config
7272
networks:
7373
redisnet:
7474
ipv4_address: 10.33.33.2
@@ -77,68 +77,11 @@ services:
7777
image: redis:6.2.7
7878
volumes:
7979
- ./test/:/test/:cached
80-
command: redis-server /test/redis-cluster.config
80+
command: redis-server /test/redis.config
8181
networks:
8282
redisnet:
8383
ipv4_address: 10.33.33.3
8484

85-
bredis_3:
86-
image: redis:6.2.7
87-
volumes:
88-
- ./test/:/test/:cached
89-
command: redis-server /test/redis-cluster.config
90-
networks:
91-
redisnet:
92-
ipv4_address: 10.33.33.4
93-
94-
bredis_4:
95-
image: redis:6.2.7
96-
volumes:
97-
- ./test/:/test/:cached
98-
command: redis-server /test/redis-cluster.config
99-
networks:
100-
redisnet:
101-
ipv4_address: 10.33.33.5
102-
103-
bredis_5:
104-
image: redis:6.2.7
105-
volumes:
106-
- ./test/:/test/:cached
107-
command: redis-server /test/redis-cluster.config
108-
networks:
109-
redisnet:
110-
ipv4_address: 10.33.33.6
111-
112-
bredis_6:
113-
image: redis:6.2.7
114-
volumes:
115-
- ./test/:/test/:cached
116-
command: redis-server /test/redis-cluster.config
117-
networks:
118-
redisnet:
119-
ipv4_address: 10.33.33.7
120-
# TODO(#6517): remove bredis_clusterer.
121-
bredis_clusterer:
122-
image: redis:6.2.7
123-
environment:
124-
BOULDER_CONFIG_DIR: *boulder_config_dir
125-
volumes:
126-
- ./test/:/test/:cached
127-
- ./cluster/:/cluster/:cached
128-
command: /test/wait-for-it.sh 10.33.33.2 4218 /test/redis-create.sh
129-
depends_on:
130-
- bredis_1
131-
- bredis_2
132-
- bredis_3
133-
- bredis_4
134-
- bredis_5
135-
- bredis_6
136-
networks:
137-
redisnet:
138-
ipv4_address: 10.33.33.10
139-
aliases:
140-
- boulder-redis-clusterer
141-
14285
bconsul:
14386
image: hashicorp/consul:1.13.1
14487
volumes:

docs/redis.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# Redis
22

3-
TODO(#6517): Update this to reflect the use of Redis Ring.
4-
5-
We use Redis Cluster for OCSP. The Boulder dev environment stands up a cluster
6-
of 6 nodes, with 3 primaries and 3 replicas. Check docker-compose.yml for
7-
details of those.
8-
9-
The initial setup is done by test/redis-create.sh, which assigns all the
10-
individual Redis nodes to their roles as primaries or replicas.
3+
We use Redis for OCSP. The Boulder dev environment stands up a two nodes. We use
4+
the Ring client in the github.com/redis/go-redis package to consistently hash
5+
our reads and writes across these two nodes.
116

127
## Debugging
138

@@ -19,26 +14,32 @@ The first tool you might turn to is `redis-cli`. You probably don't
1914
have redis-cli on your host, so we'll run it in a Docker container. We
2015
also need to pass some specific arguments for TLS and authentication. There's a
2116
script that handles all that for you: `test/redis-cli.sh`. First, make sure your
22-
redis cluster is running:
17+
redis is running:
2318

24-
```
25-
docker compose up bredis_clusterer
19+
```shell
20+
docker compose up boulder
2621
```
2722

28-
Then, in a different window, run:
23+
Then, in a different window, run the following to connect to `bredis_1`:
2924

30-
```
25+
```shell
3126
./test/redis-cli.sh -h 10.33.33.2
3227
```
3328

29+
Similarly, to connect to `bredis_2`:
30+
31+
```shell
32+
./test/redis-cli.sh -h 10.33.33.3
33+
```
34+
3435
You can pass any IP address for the -h (host) parameter. The full list of IP
3536
addresses for Redis nodes is in `docker-compose.yml`. You can also pass other
3637
redis-cli commandline parameters. They'll get passed through.
3738

3839
You may want to go a level deeper and communicate with a Redis node using the
3940
Redis protocol. Here's the command to do that (run from the Boulder root):
4041

41-
```
42+
```shell
4243
openssl s_client -connect 10.33.33.2:4218 \
4344
-CAfile test/redis-tls/minica.pem \
4445
-cert test/redis-tls/boulder/cert.pem \

ocsp/responder/redis/redis_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type redisSource struct {
4949
// NewRedisSource returns a responder.Source which will look up OCSP responses in a
5050
// Redis table.
5151
func NewRedisSource(
52-
client rocsp.Writer,
52+
client *rocsp.RWClient,
5353
signer responder.Source,
5454
liveSigningPeriod time.Duration,
5555
clk clock.Clock,

0 commit comments

Comments
 (0)