Skip to content

Commit 6c6da76

Browse files
ROCSP: Replace Redis Cluster with a consistently sharded all-primary nodes (#6516)
1 parent a67237a commit 6c6da76

File tree

17 files changed

+544
-96
lines changed

17 files changed

+544
-96
lines changed

cmd/ocsp-responder/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ as generated by Boulder's ceremony command.
179179
cmd.FailOnError(err, "While initializing dbMap")
180180

181181
// Set up the redis source and the combined multiplex source.
182-
rocspReader, err := rocsp_config.MakeClient(&c.OCSPResponder.Redis, clk, scope)
182+
rocspRWClient, err := rocsp_config.MakeClient(&c.OCSPResponder.Redis, clk, scope)
183183
cmd.FailOnError(err, "Could not make redis client")
184184

185-
err = rocspReader.Ping(context.Background())
185+
err = rocspRWClient.Ping(context.Background())
186186
cmd.FailOnError(err, "pinging Redis")
187187

188188
liveSigningPeriod := c.OCSPResponder.LiveSigningPeriod.Duration
@@ -203,7 +203,7 @@ as generated by Boulder's ceremony command.
203203
}
204204
liveSource := live.New(rac, int64(maxInflight), c.OCSPResponder.MaxSigningWaiters)
205205

206-
rocspSource, err := redis_responder.NewRedisSource(rocspReader, liveSource, liveSigningPeriod, clk, scope, logger)
206+
rocspSource, err := redis_responder.NewRedisSource(rocspRWClient, liveSource, liveSigningPeriod, clk, scope, logger)
207207
cmd.FailOnError(err, "Could not create redis source")
208208

209209
var sac sapb.StorageAuthorityReadOnlyClient

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.WritingClient
23+
redis rocsp.Writer
2424
db *db.WrappedMap // optional
2525
ocspGenerator capb.OCSPGeneratorClient
2626
clk clock.Clock

cmd/rocsp-tool/client_test.go

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

@@ -22,7 +23,35 @@ import (
2223
"google.golang.org/grpc"
2324
)
2425

25-
func makeClient() (*rocsp.WritingClient, clock.Clock) {
26+
func makeClient() (*rocsp.RWClient, clock.Clock) {
27+
CACertFile := "../../test/redis-tls/minica.pem"
28+
CertFile := "../../test/redis-tls/boulder/cert.pem"
29+
KeyFile := "../../test/redis-tls/boulder/key.pem"
30+
tlsConfig := cmd.TLSConfig{
31+
CACertFile: &CACertFile,
32+
CertFile: &CertFile,
33+
KeyFile: &KeyFile,
34+
}
35+
tlsConfig2, err := tlsConfig.Load()
36+
if err != nil {
37+
panic(err)
38+
}
39+
40+
rdb := redis.NewRing(&redis.RingOptions{
41+
Addrs: map[string]string{
42+
"shard1": "10.33.33.8:4218",
43+
"shard2": "10.33.33.9:4218",
44+
},
45+
Username: "unittest-rw",
46+
Password: "824968fa490f4ecec1e52d5e34916bdb60d45f8d",
47+
TLSConfig: tlsConfig2,
48+
})
49+
clk := clock.NewFake()
50+
return rocsp.NewWritingClient(rdb, 500*time.Millisecond, clk, metrics.NoopRegisterer), clk
51+
}
52+
53+
// TODO(#6517) remove this helper.
54+
func makeClusterClient() (*rocsp.CRWClient, clock.Clock) {
2655
CACertFile := "../../test/redis-tls/minica.pem"
2756
CertFile := "../../test/redis-tls/boulder/cert.pem"
2857
KeyFile := "../../test/redis-tls/boulder/key.pem"
@@ -43,7 +72,8 @@ func makeClient() (*rocsp.WritingClient, clock.Clock) {
4372
TLSConfig: tlsConfig2,
4473
})
4574
clk := clock.NewFake()
46-
return rocsp.NewWritingClient(rdb, 500*time.Millisecond, clk, metrics.NoopRegisterer), clk
75+
76+
return rocsp.NewClusterWritingClient(rdb, 5*time.Second, clk, metrics.NoopRegisterer), clk
4777
}
4878

4979
func TestGetStartingID(t *testing.T) {
@@ -79,7 +109,14 @@ func TestGetStartingID(t *testing.T) {
79109
}
80110

81111
func TestStoreResponse(t *testing.T) {
82-
redisClient, clk := makeClient()
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+
}
83120

84121
issuer, err := core.LoadCert("../../test/hierarchy/int-e1.cert.pem")
85122
test.AssertNotError(t, err, "loading int-e1")
@@ -116,7 +153,14 @@ func (mog mockOCSPGenerator) GenerateOCSP(ctx context.Context, in *capb.Generate
116153
}
117154

118155
func TestLoadFromDB(t *testing.T) {
119-
redisClient, clk := makeClient()
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+
}
120164

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

docker-compose.next.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,28 @@ services:
33
boulder:
44
environment:
55
FAKE_DNS: 10.77.77.77
6-
BOULDER_CONFIG_DIR: test/config-next
6+
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: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
image: &boulder_image letsencrypt/boulder-tools:${BOULDER_TOOLS_TAG:-go1.19.2_2022-10-05}
99
environment:
1010
FAKE_DNS: 10.77.77.77
11-
BOULDER_CONFIG_DIR: test/config
11+
BOULDER_CONFIG_DIR: &boulder_config_dir test/config
1212
GOFLAGS: -mod=vendor
1313
# Go 1.18 turned off SHA-1 validation on CSRs (and certs, but that doesn't
1414
# affect us) by default, but it can be turned back on with the x509sha1
@@ -63,64 +63,67 @@ services:
6363
# small.
6464
command: mysqld --bind-address=0.0.0.0 --slow-query-log --log-output=TABLE --log-queries-not-using-indexes=ON
6565
logging:
66-
driver: none
67-
66+
driver: none
67+
# TODO(#6517): replace all bredis_ services with those from
68+
# docker-compose.next.yml.
6869
bredis_1:
6970
image: redis:6.2.7
7071
volumes:
7172
- ./test/:/test/:cached
72-
command: redis-server /test/redis.config
73+
command: redis-server /test/redis-cluster.config
7374
networks:
7475
redisnet:
75-
ipv4_address: 10.33.33.2
76+
ipv4_address: 10.33.33.2
7677

7778
bredis_2:
7879
image: redis:6.2.7
7980
volumes:
8081
- ./test/:/test/:cached
81-
command: redis-server /test/redis.config
82+
command: redis-server /test/redis-cluster.config
8283
networks:
8384
redisnet:
84-
ipv4_address: 10.33.33.3
85+
ipv4_address: 10.33.33.3
8586

8687
bredis_3:
8788
image: redis:6.2.7
8889
volumes:
8990
- ./test/:/test/:cached
90-
command: redis-server /test/redis.config
91+
command: redis-server /test/redis-cluster.config
9192
networks:
9293
redisnet:
93-
ipv4_address: 10.33.33.4
94+
ipv4_address: 10.33.33.4
9495

9596
bredis_4:
9697
image: redis:6.2.7
9798
volumes:
9899
- ./test/:/test/:cached
99-
command: redis-server /test/redis.config
100+
command: redis-server /test/redis-cluster.config
100101
networks:
101102
redisnet:
102-
ipv4_address: 10.33.33.5
103+
ipv4_address: 10.33.33.5
103104

104105
bredis_5:
105106
image: redis:6.2.7
106107
volumes:
107108
- ./test/:/test/:cached
108-
command: redis-server /test/redis.config
109+
command: redis-server /test/redis-cluster.config
109110
networks:
110111
redisnet:
111-
ipv4_address: 10.33.33.6
112+
ipv4_address: 10.33.33.6
112113

113114
bredis_6:
114115
image: redis:6.2.7
115116
volumes:
116117
- ./test/:/test/:cached
117-
command: redis-server /test/redis.config
118+
command: redis-server /test/redis-cluster.config
118119
networks:
119120
redisnet:
120-
ipv4_address: 10.33.33.7
121-
121+
ipv4_address: 10.33.33.7
122+
# TODO(#6517): remove bredis_clusterer.
122123
bredis_clusterer:
123124
image: redis:6.2.7
125+
environment:
126+
BOULDER_CONFIG_DIR: *boulder_config_dir
124127
volumes:
125128
- ./test/:/test/:cached
126129
- ./cluster/:/cluster/:cached
@@ -134,9 +137,9 @@ services:
134137
- bredis_6
135138
networks:
136139
redisnet:
137-
ipv4_address: 10.33.33.10
138-
aliases:
139-
- boulder-redis-clusterer
140+
ipv4_address: 10.33.33.10
141+
aliases:
142+
- boulder-redis-clusterer
140143

141144
bconsul:
142145
image: hashicorp/consul:1.13.1
@@ -152,7 +155,7 @@ services:
152155
environment:
153156
GO111MODULE: "on"
154157
GOFLAGS: -mod=vendor
155-
BOULDER_CONFIG_DIR: test/config
158+
BOULDER_CONFIG_DIR: *boulder_config_dir
156159
networks:
157160
- bluenet
158161
volumes:

docs/redis.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Redis
22

3+
TODO(#6517): Update this to reflect the use of Redis Ring.
4+
35
We use Redis Cluster for OCSP. The Boulder dev environment stands up a cluster
46
of 6 nodes, with 3 primaries and 3 replicas. Check docker-compose.yml for
57
details of those.

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.WritingClient,
52+
client rocsp.Writer,
5353
signer responder.Source,
5454
liveSigningPeriod time.Duration,
5555
clk clock.Clock,

0 commit comments

Comments
 (0)