diff --git a/go.mod b/go.mod index dc06343db7..7da926cf52 100644 --- a/go.mod +++ b/go.mod @@ -136,7 +136,7 @@ require ( golang.org/x/text v0.12.0 golang.org/x/time v0.3.0 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 - google.golang.org/grpc v1.57.0 + google.golang.org/grpc v1.58.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/klog/v2 v2.100.1 diff --git a/go.sum b/go.sum index 01230fbcb4..a88243ad81 100644 --- a/go.sum +++ b/go.sum @@ -404,8 +404,8 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.10.1 h1:c0g45+xCJhdgFGw7a5QAfdS4byAbud7miNWJ1WwEVf8= -github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= 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 google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= -google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o= +google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/internal/app/apid/pkg/backend/apid.go b/internal/app/apid/pkg/backend/apid.go index fc86863d3f..909b34aaeb 100644 --- a/internal/app/apid/pkg/backend/apid.go +++ b/internal/app/apid/pkg/backend/apid.go @@ -102,6 +102,7 @@ func (a *APID) GetConnection(ctx context.Context, fullMethodName string) (contex MinConnectTimeout: 20 * time.Second, }), grpc.WithCodec(proxy.Codec()), //nolint:staticcheck + grpc.WithSharedWriteBuffer(true), ) return outCtx, a.conn, err diff --git a/internal/app/machined/pkg/controllers/runtime/events_sink.go b/internal/app/machined/pkg/controllers/runtime/events_sink.go index f955b770bc..517276e713 100644 --- a/internal/app/machined/pkg/controllers/runtime/events_sink.go +++ b/internal/app/machined/pkg/controllers/runtime/events_sink.go @@ -160,7 +160,12 @@ func (ctrl *EventsSinkController) Run(ctx context.Context, r controller.Runtime, // establish connection logger.Debug("establishing connection to event sink", zap.String("endpoint", cfg.TypedSpec().Endpoint)) - conn, err = grpc.DialContext(ctx, cfg.TypedSpec().Endpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) + conn, err = grpc.DialContext( + ctx, + cfg.TypedSpec().Endpoint, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithSharedWriteBuffer(true), + ) if err != nil { return fmt.Errorf("error establishing connection to event sink: %w", err) } diff --git a/internal/app/machined/pkg/controllers/siderolink/manager.go b/internal/app/machined/pkg/controllers/siderolink/manager.go index e4f7457a55..f50d7e5718 100644 --- a/internal/app/machined/pkg/controllers/siderolink/manager.go +++ b/internal/app/machined/pkg/controllers/siderolink/manager.go @@ -181,7 +181,12 @@ func (ctrl *ManagerController) Run(ctx context.Context, r controller.Runtime, lo connCtx, connCtxCancel := context.WithTimeout(ctx, 10*time.Second) defer connCtxCancel() - conn, connErr := grpc.DialContext(connCtx, parsedEndpoint.Host, grpc.WithTransportCredentials(transportCredentials)) + conn, connErr := grpc.DialContext( + connCtx, + parsedEndpoint.Host, + grpc.WithTransportCredentials(transportCredentials), + grpc.WithSharedWriteBuffer(true), + ) if connErr != nil { return nil, fmt.Errorf("error dialing SideroLink endpoint %q: %w", stringEndpoint, connErr) } diff --git a/internal/app/machined/pkg/system/services/apid.go b/internal/app/machined/pkg/system/services/apid.go index 33af3f04fd..29353607ce 100644 --- a/internal/app/machined/pkg/system/services/apid.go +++ b/internal/app/machined/pkg/system/services/apid.go @@ -99,7 +99,9 @@ func (o *APID) PreFunc(ctx context.Context, r runtime.Runtime) error { return err } - o.runtimeServer = grpc.NewServer() + o.runtimeServer = grpc.NewServer( + grpc.SharedWriteBuffer(true), + ) v1alpha1.RegisterStateServer(o.runtimeServer, server.NewState(resources)) go o.runtimeServer.Serve(listener) //nolint:errcheck diff --git a/internal/app/machined/pkg/system/services/trustd.go b/internal/app/machined/pkg/system/services/trustd.go index 2e0850a05b..4bb0d50049 100644 --- a/internal/app/machined/pkg/system/services/trustd.go +++ b/internal/app/machined/pkg/system/services/trustd.go @@ -97,7 +97,9 @@ func (t *Trustd) PreFunc(ctx context.Context, r runtime.Runtime) error { return err } - t.runtimeServer = grpc.NewServer() + t.runtimeServer = grpc.NewServer( + grpc.SharedWriteBuffer(true), + ) v1alpha1.RegisterStateServer(t.runtimeServer, server.NewState(resources)) go t.runtimeServer.Serve(listener) //nolint:errcheck diff --git a/internal/app/trustd/main.go b/internal/app/trustd/main.go index def648d2d6..12eb070be1 100644 --- a/internal/app/trustd/main.go +++ b/internal/app/trustd/main.go @@ -66,7 +66,11 @@ func trustdMain() error { var err error - runtimeConn, err := grpc.Dial("unix://"+constants.TrustdRuntimeSocketPath, grpc.WithTransportCredentials(insecure.NewCredentials())) + runtimeConn, err := grpc.Dial( + "unix://"+constants.TrustdRuntimeSocketPath, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithSharedWriteBuffer(true), + ) if err != nil { return fmt.Errorf("failed to dial runtime connection: %w", err) } diff --git a/internal/pkg/cri/client.go b/internal/pkg/cri/client.go index 0912827d5a..a473720a53 100644 --- a/internal/pkg/cri/client.go +++ b/internal/pkg/cri/client.go @@ -39,6 +39,7 @@ func NewClient(endpoint string, connectionTimeout time.Duration) (*Client, error grpc.WithBackoffMaxDelay(3*time.Second), //nolint:staticcheck grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)), grpc.WithContextDialer(dialer.DialUnix()), + grpc.WithSharedWriteBuffer(true), ) if err != nil { return nil, fmt.Errorf("error connecting to CRI: %w", err) diff --git a/internal/pkg/encryption/keys/kms.go b/internal/pkg/encryption/keys/kms.go index 9ac1739944..cb9fcc3326 100644 --- a/internal/pkg/encryption/keys/kms.go +++ b/internal/pkg/encryption/keys/kms.go @@ -133,5 +133,10 @@ func (h *KMSKeyHandler) getConn(ctx context.Context) (*grpc.ClientConn, error) { transportCredentials = credentials.NewTLS(&tls.Config{}) } - return grpc.DialContext(ctx, endpoint.Host, grpc.WithTransportCredentials(transportCredentials)) + return grpc.DialContext( + ctx, + endpoint.Host, + grpc.WithTransportCredentials(transportCredentials), + grpc.WithSharedWriteBuffer(true), + ) } diff --git a/internal/pkg/etcd/etcd.go b/internal/pkg/etcd/etcd.go index 6febc8f401..e61840eaf4 100644 --- a/internal/pkg/etcd/etcd.go +++ b/internal/pkg/etcd/etcd.go @@ -56,7 +56,7 @@ func NewClient(ctx context.Context, endpoints []string, dialOpts ...grpc.DialOpt Endpoints: endpoints, DialTimeout: 5 * time.Second, Context: ctx, - DialOptions: dialOpts, + DialOptions: append(dialOpts, grpc.WithSharedWriteBuffer(true)), TLS: tlsConfig, Logger: zap.NewNop(), }) diff --git a/pkg/grpc/factory/factory.go b/pkg/grpc/factory/factory.go index 94aec48c9c..9d7cf27b60 100644 --- a/pkg/grpc/factory/factory.go +++ b/pkg/grpc/factory/factory.go @@ -189,6 +189,7 @@ func NewDefaultOptions(setters ...Option) *Options { grpc.InitialConnWindowSize(65535*16), grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(opts.UnaryInterceptors...)), grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(opts.StreamInterceptors...)), + grpc.SharedWriteBuffer(true), ) return opts diff --git a/pkg/grpc/middleware/auth/basic/basic.go b/pkg/grpc/middleware/auth/basic/basic.go index f7e71ddcb8..0b6aae6083 100644 --- a/pkg/grpc/middleware/auth/basic/basic.go +++ b/pkg/grpc/middleware/auth/basic/basic.go @@ -35,6 +35,7 @@ func NewConnection(address string, creds credentials.PerRPCCredentials, ca *x509 grpcOpts := []grpc.DialOption{ grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)), grpc.WithPerRPCCredentials(creds), + grpc.WithSharedWriteBuffer(true), } conn, err = grpc.Dial(address, grpcOpts...) diff --git a/pkg/grpc/proxy/backend/local.go b/pkg/grpc/proxy/backend/local.go index 0e4fac4f17..ec367ff86b 100644 --- a/pkg/grpc/proxy/backend/local.go +++ b/pkg/grpc/proxy/backend/local.go @@ -61,7 +61,7 @@ func (l *Local) GetConnection(ctx context.Context, fullMethodName string) (conte "unix:"+l.socketPath, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithCodec(proxy.Codec()), //nolint:staticcheck - + grpc.WithSharedWriteBuffer(true), ) return outCtx, l.conn, err diff --git a/pkg/machinery/client/connection.go b/pkg/machinery/client/connection.go index 15f99a565a..6500cc71bb 100644 --- a/pkg/machinery/client/connection.go +++ b/pkg/machinery/client/connection.go @@ -44,6 +44,7 @@ func (c *Client) getConn(ctx context.Context, opts ...grpc.DialOption) (*grpcCon // grpc.UseCompressor(gzip.Name), grpc.MaxCallRecvMsgSize(constants.GRPCMaxMessageSize), ), + grpc.WithSharedWriteBuffer(true), } dialOpts = append(dialOpts, c.options.grpcDialOptions...) dialOpts = append(dialOpts, opts...) diff --git a/pkg/machinery/go.mod b/pkg/machinery/go.mod index 214dfd86e8..90acf13649 100644 --- a/pkg/machinery/go.mod +++ b/pkg/machinery/go.mod @@ -27,7 +27,7 @@ require ( github.com/siderolabs/protoenc v0.2.0 github.com/stretchr/testify v1.8.4 google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d - google.golang.org/grpc v1.57.0 + google.golang.org/grpc v1.58.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/pkg/machinery/go.sum b/pkg/machinery/go.sum index bcf567c23f..76ff5e187f 100644 --- a/pkg/machinery/go.sum +++ b/pkg/machinery/go.sum @@ -232,8 +232,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1: google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= -google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o= +google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=