Skip to content
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

Add gRPC MaxConnectionAge config. #5311

Merged
merged 2 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ type GRPCServerConfig struct {
// (SANs). The server will reject clients that do not present a certificate
// with a SAN present on the `ClientNames` list.
ClientNames []string `json:"clientNames"`
// How long a connection may live before the server sends a GoAway to the
jsha marked this conversation as resolved.
Show resolved Hide resolved
// client. Because gRPC connections re-resolve DNS after a connection close,
// this controls how long it takes before a client learns about changes to its
// backends.
// https://pkg.go.dev/google.golang.org/grpc/keepalive#ServerParameters
MaxConnectionAge ConfigDuration
}

// PortConfig specifies what ports the VA should call to on the remote
Expand Down
14 changes: 11 additions & 3 deletions grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"errors"
"net"

"github.com/grpc-ecosystem/go-grpc-prometheus"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/jmhodges/clock"
"github.com/letsencrypt/boulder/cmd"
bcreds "github.com/letsencrypt/boulder/grpc/creds"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
)

// CodedError is a alias required to appease go vet
Expand Down Expand Up @@ -42,10 +43,17 @@ func NewServer(c *cmd.GRPCServerConfig, tlsConfig *tls.Config, metrics serverMet
}

si := newServerInterceptor(metrics, clk)
return grpc.NewServer(
options := []grpc.ServerOption{
grpc.Creds(creds),
grpc.UnaryInterceptor(si.intercept),
), l, nil
}
if c.MaxConnectionAge.Duration > 0 {
options = append(options,
grpc.KeepaliveParams(keepalive.ServerParameters{
MaxConnectionAge: c.MaxConnectionAge.Duration,
}))
}
return grpc.NewServer(options...), l, nil
}

// serverMetrics is a struct type used to return a few registered metrics from
Expand Down
1 change: 1 addition & 0 deletions test/config-next/akamai-purger.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"grpc": {
"address": ":9099",
"maxConnectionAge": "30s",
"clientNames": [
"health-checker.boulder",
"ra.boulder"
Expand Down
2 changes: 2 additions & 0 deletions test/config-next/ca-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
},
"hostnamePolicyFile": "test/hostname-policy.yaml",
"grpcCA": {
"maxConnectionAge": "30s",
"address": ":9093",
"clientNames": [
"health-checker.boulder",
"ra.boulder"
]
},
"grpcOCSPGenerator": {
"maxConnectionAge": "30s",
"address": ":9096",
"clientNames": [
"health-checker.boulder",
Expand Down
2 changes: 2 additions & 0 deletions test/config-next/ca-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
},
"hostnamePolicyFile": "test/hostname-policy.yaml",
"grpcCA": {
"maxConnectionAge": "30s",
"address": ":9093",
"clientNames": [
"health-checker.boulder",
"ra.boulder"
]
},
"grpcOCSPGenerator": {
"maxConnectionAge": "30s",
"address": ":9096",
"clientNames": [
"health-checker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/nonce.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"debugAddr": ":8111",
"grpc": {
"maxConnectionAge": "30s",
"address": ":9101",
"clientNames": [
"health-checker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/publisher.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"blockProfileRate": 1000000000,
"debugAddr": ":8009",
"grpc": {
"maxConnectionAge": "30s",
"address": ":9091",
"clientNames": [
"health-checker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/ra.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"timeout": "15s"
},
"grpc": {
"maxConnectionAge": "30s",
"address": ":9094",
"clientNames": [
"admin-revoker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/sa.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"keyFile": "test/grpc-creds/sa.boulder/key.pem"
},
"grpc": {
"maxConnectionAge": "30s",
"address": ":9095",
"clientNames": [
"admin-revoker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/va-remote-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"keyFile": "test/grpc-creds/va.boulder/key.pem"
},
"grpc": {
"maxConnectionAge": "30s",
"address": ":9097",
"clientNames": [
"health-checker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/va-remote-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"keyFile": "test/grpc-creds/va.boulder/key.pem"
},
"grpc": {
"maxConnectionAge": "30s",
"address": ":9098",
"clientNames": [
"health-checker.boulder",
Expand Down
1 change: 1 addition & 0 deletions test/config-next/va.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"keyFile": "test/grpc-creds/va.boulder/key.pem"
},
"grpc": {
"maxConnectionAge": "30s",
"address": ":9092",
"clientNames": [
"health-checker.boulder",
Expand Down