Skip to content

Commit e5b3814

Browse files
committed
add optional gRPC max message size limit to trillian logserver and logsigner (google#3801)
* add optional gRPC max message size limit to trillian logserver and logsigner Signed-off-by: Firas Ghanmi <fghanmi@redhat.com> * update CHANGELOG.md Signed-off-by: Firas Ghanmi <fghanmi@redhat.com> --------- Signed-off-by: Firas Ghanmi <fghanmi@redhat.com>
1 parent 3c6adcb commit e5b3814

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Bump golangci-lint to v2.1.6
66
* Fix leader resignation during a graceful shutdown by @osmman in https://github.com/google/trillian/pull/3790
7+
* Add optional gRPC message size limit via `--max_msg_size_bytes` flag by @fghanmi in https://github.com/google/trillian/pull/3801
78

89
## v1.7.2
910

cmd/trillian_log_server/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ var (
7676
// Profiling related flags.
7777
cpuProfile = flag.String("cpuprofile", "", "If set, write CPU profile to this file")
7878
memProfile = flag.String("memprofile", "", "If set, write memory profile to this file")
79+
maxMsgSize = flag.Int("max_msg_size_bytes", 0, "Optional max gRPC message size in bytes")
7980
)
8081

8182
func main() {
@@ -107,6 +108,9 @@ func main() {
107108
options = append(options, opts...)
108109
}
109110

111+
if *maxMsgSize > 0 {
112+
options = append(options, grpc.MaxRecvMsgSize(*maxMsgSize))
113+
}
110114
sp, err := storage.NewProvider(*storageSystem, mf)
111115
if err != nil {
112116
klog.Exitf("Failed to get storage provider: %v", err)

cmd/trillian_log_signer/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var (
8484
// Profiling related flags.
8585
cpuProfile = flag.String("cpuprofile", "", "If set, write CPU profile to this file")
8686
memProfile = flag.String("memprofile", "", "If set, write memory profile to this file")
87+
maxMsgSize = flag.Int("max_msg_size_bytes", 0, "Optional max gRPC message size in bytes")
8788
)
8889

8990
func main() {
@@ -194,12 +195,17 @@ func main() {
194195
defer pprof.StopCPUProfile()
195196
}
196197

198+
var options []grpc.ServerOption
199+
if *maxMsgSize > 0 {
200+
options = append(options, grpc.MaxRecvMsgSize(*maxMsgSize))
201+
}
197202
m := serverutil.Main{
198203
RPCEndpoint: *rpcEndpoint,
199204
HTTPEndpoint: *httpEndpoint,
200205
TLSCertFile: *tlsCertFile,
201206
TLSKeyFile: *tlsKeyFile,
202207
StatsPrefix: "logsigner",
208+
ExtraOptions: options,
203209
DBClose: sp.Close,
204210
Registry: registry,
205211
RegisterServerFn: func(s *grpc.Server, _ extension.Registry) error { return nil },

0 commit comments

Comments
 (0)