Skip to content

Commit ded9920

Browse files
fghanmihimaschal
authored andcommitted
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 7bf928a commit ded9920

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
@@ -77,6 +77,7 @@ var (
7777
// Profiling related flags.
7878
cpuProfile = flag.String("cpuprofile", "", "If set, write CPU profile to this file")
7979
memProfile = flag.String("memprofile", "", "If set, write memory profile to this file")
80+
maxMsgSize = flag.Int("max_msg_size_bytes", 0, "Optional max gRPC message size in bytes")
8081
)
8182

8283
func main() {
@@ -114,6 +115,9 @@ func main() {
114115
options = append(options, opts...)
115116
}
116117

118+
if *maxMsgSize > 0 {
119+
options = append(options, grpc.MaxRecvMsgSize(*maxMsgSize))
120+
}
117121
sp, err := storage.NewProvider(*storageSystem, mf)
118122
if err != nil {
119123
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
@@ -85,6 +85,7 @@ var (
8585
// Profiling related flags.
8686
cpuProfile = flag.String("cpuprofile", "", "If set, write CPU profile to this file")
8787
memProfile = flag.String("memprofile", "", "If set, write memory profile to this file")
88+
maxMsgSize = flag.Int("max_msg_size_bytes", 0, "Optional max gRPC message size in bytes")
8889
)
8990

9091
func main() {
@@ -200,12 +201,17 @@ func main() {
200201
defer pprof.StopCPUProfile()
201202
}
202203

204+
var options []grpc.ServerOption
205+
if *maxMsgSize > 0 {
206+
options = append(options, grpc.MaxRecvMsgSize(*maxMsgSize))
207+
}
203208
m := serverutil.Main{
204209
RPCEndpoint: *rpcEndpoint,
205210
HTTPEndpoint: *httpEndpoint,
206211
TLSCertFile: *tlsCertFile,
207212
TLSKeyFile: *tlsKeyFile,
208213
StatsPrefix: "logsigner",
214+
ExtraOptions: options,
209215
DBClose: sp.Close,
210216
Registry: registry,
211217
RegisterServerFn: func(s *grpc.Server, _ extension.Registry) error { return nil },

0 commit comments

Comments
 (0)