Skip to content

Commit a096f05

Browse files
committed
chore: update gRPC library and enable shared write buffers
Fixes #7576 See grpc/grpc-go#6309 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 9e78fec commit a096f05

File tree

17 files changed

+44
-16
lines changed

17 files changed

+44
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ require (
136136
golang.org/x/text v0.12.0
137137
golang.org/x/time v0.3.0
138138
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
139-
google.golang.org/grpc v1.57.0
139+
google.golang.org/grpc v1.58.0
140140
google.golang.org/protobuf v1.31.0
141141
gopkg.in/yaml.v3 v3.0.1
142142
k8s.io/klog/v2 v2.100.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
404404
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
405405
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
406406
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
407-
github.com/envoyproxy/protoc-gen-validate v0.10.1 h1:c0g45+xCJhdgFGw7a5QAfdS4byAbud7miNWJ1WwEVf8=
408-
github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss=
407+
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
408+
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
409409
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
410410
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
411411
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
@@ -1688,8 +1688,8 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5
16881688
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
16891689
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
16901690
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
1691-
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
1692-
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
1691+
google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o=
1692+
google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
16931693
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
16941694
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
16951695
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

internal/app/apid/pkg/backend/apid.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func (a *APID) GetConnection(ctx context.Context, fullMethodName string) (contex
102102
MinConnectTimeout: 20 * time.Second,
103103
}),
104104
grpc.WithCodec(proxy.Codec()), //nolint:staticcheck
105+
grpc.WithSharedWriteBuffer(true),
105106
)
106107

107108
return outCtx, a.conn, err

internal/app/machined/pkg/controllers/runtime/events_sink.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ func (ctrl *EventsSinkController) Run(ctx context.Context, r controller.Runtime,
160160
// establish connection
161161
logger.Debug("establishing connection to event sink", zap.String("endpoint", cfg.TypedSpec().Endpoint))
162162

163-
conn, err = grpc.DialContext(ctx, cfg.TypedSpec().Endpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
163+
conn, err = grpc.DialContext(
164+
ctx,
165+
cfg.TypedSpec().Endpoint,
166+
grpc.WithTransportCredentials(insecure.NewCredentials()),
167+
grpc.WithSharedWriteBuffer(true),
168+
)
164169
if err != nil {
165170
return fmt.Errorf("error establishing connection to event sink: %w", err)
166171
}

internal/app/machined/pkg/controllers/siderolink/manager.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ func (ctrl *ManagerController) Run(ctx context.Context, r controller.Runtime, lo
181181
connCtx, connCtxCancel := context.WithTimeout(ctx, 10*time.Second)
182182
defer connCtxCancel()
183183

184-
conn, connErr := grpc.DialContext(connCtx, parsedEndpoint.Host, grpc.WithTransportCredentials(transportCredentials))
184+
conn, connErr := grpc.DialContext(
185+
connCtx,
186+
parsedEndpoint.Host,
187+
grpc.WithTransportCredentials(transportCredentials),
188+
grpc.WithSharedWriteBuffer(true),
189+
)
185190
if connErr != nil {
186191
return nil, fmt.Errorf("error dialing SideroLink endpoint %q: %w", stringEndpoint, connErr)
187192
}

internal/app/machined/pkg/system/services/apid.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ func (o *APID) PreFunc(ctx context.Context, r runtime.Runtime) error {
9999
return err
100100
}
101101

102-
o.runtimeServer = grpc.NewServer()
102+
o.runtimeServer = grpc.NewServer(
103+
grpc.SharedWriteBuffer(true),
104+
)
103105
v1alpha1.RegisterStateServer(o.runtimeServer, server.NewState(resources))
104106

105107
go o.runtimeServer.Serve(listener) //nolint:errcheck

internal/app/machined/pkg/system/services/trustd.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ func (t *Trustd) PreFunc(ctx context.Context, r runtime.Runtime) error {
9797
return err
9898
}
9999

100-
t.runtimeServer = grpc.NewServer()
100+
t.runtimeServer = grpc.NewServer(
101+
grpc.SharedWriteBuffer(true),
102+
)
101103
v1alpha1.RegisterStateServer(t.runtimeServer, server.NewState(resources))
102104

103105
go t.runtimeServer.Serve(listener) //nolint:errcheck

internal/app/trustd/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ func trustdMain() error {
6666

6767
var err error
6868

69-
runtimeConn, err := grpc.Dial("unix://"+constants.TrustdRuntimeSocketPath, grpc.WithTransportCredentials(insecure.NewCredentials()))
69+
runtimeConn, err := grpc.Dial(
70+
"unix://"+constants.TrustdRuntimeSocketPath,
71+
grpc.WithTransportCredentials(insecure.NewCredentials()),
72+
grpc.WithSharedWriteBuffer(true),
73+
)
7074
if err != nil {
7175
return fmt.Errorf("failed to dial runtime connection: %w", err)
7276
}

internal/pkg/cri/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func NewClient(endpoint string, connectionTimeout time.Duration) (*Client, error
3939
grpc.WithBackoffMaxDelay(3*time.Second), //nolint:staticcheck
4040
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)),
4141
grpc.WithContextDialer(dialer.DialUnix()),
42+
grpc.WithSharedWriteBuffer(true),
4243
)
4344
if err != nil {
4445
return nil, fmt.Errorf("error connecting to CRI: %w", err)

internal/pkg/encryption/keys/kms.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,10 @@ func (h *KMSKeyHandler) getConn(ctx context.Context) (*grpc.ClientConn, error) {
133133
transportCredentials = credentials.NewTLS(&tls.Config{})
134134
}
135135

136-
return grpc.DialContext(ctx, endpoint.Host, grpc.WithTransportCredentials(transportCredentials))
136+
return grpc.DialContext(
137+
ctx,
138+
endpoint.Host,
139+
grpc.WithTransportCredentials(transportCredentials),
140+
grpc.WithSharedWriteBuffer(true),
141+
)
137142
}

internal/pkg/etcd/etcd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewClient(ctx context.Context, endpoints []string, dialOpts ...grpc.DialOpt
5656
Endpoints: endpoints,
5757
DialTimeout: 5 * time.Second,
5858
Context: ctx,
59-
DialOptions: dialOpts,
59+
DialOptions: append(dialOpts, grpc.WithSharedWriteBuffer(true)),
6060
TLS: tlsConfig,
6161
Logger: zap.NewNop(),
6262
})

pkg/grpc/factory/factory.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func NewDefaultOptions(setters ...Option) *Options {
189189
grpc.InitialConnWindowSize(65535*16),
190190
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(opts.UnaryInterceptors...)),
191191
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(opts.StreamInterceptors...)),
192+
grpc.SharedWriteBuffer(true),
192193
)
193194

194195
return opts

pkg/grpc/middleware/auth/basic/basic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func NewConnection(address string, creds credentials.PerRPCCredentials, ca *x509
3535
grpcOpts := []grpc.DialOption{
3636
grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)),
3737
grpc.WithPerRPCCredentials(creds),
38+
grpc.WithSharedWriteBuffer(true),
3839
}
3940

4041
conn, err = grpc.Dial(address, grpcOpts...)

pkg/grpc/proxy/backend/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (l *Local) GetConnection(ctx context.Context, fullMethodName string) (conte
6161
"unix:"+l.socketPath,
6262
grpc.WithTransportCredentials(insecure.NewCredentials()),
6363
grpc.WithCodec(proxy.Codec()), //nolint:staticcheck
64-
64+
grpc.WithSharedWriteBuffer(true),
6565
)
6666

6767
return outCtx, l.conn, err

pkg/machinery/client/connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (c *Client) getConn(ctx context.Context, opts ...grpc.DialOption) (*grpcCon
4444
// grpc.UseCompressor(gzip.Name),
4545
grpc.MaxCallRecvMsgSize(constants.GRPCMaxMessageSize),
4646
),
47+
grpc.WithSharedWriteBuffer(true),
4748
}
4849
dialOpts = append(dialOpts, c.options.grpcDialOptions...)
4950
dialOpts = append(dialOpts, opts...)

pkg/machinery/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/siderolabs/protoenc v0.2.0
2828
github.com/stretchr/testify v1.8.4
2929
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d
30-
google.golang.org/grpc v1.57.0
30+
google.golang.org/grpc v1.58.0
3131
google.golang.org/protobuf v1.31.0
3232
gopkg.in/yaml.v3 v3.0.1
3333
)

pkg/machinery/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:
232232
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
233233
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
234234
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
235-
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
236-
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
235+
google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o=
236+
google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
237237
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
238238
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
239239
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

0 commit comments

Comments
 (0)