From a731472496ff44ab97f41b18d47b0150ccb4141a Mon Sep 17 00:00:00 2001 From: Yingrong Zhao Date: Tue, 24 Mar 2020 13:49:20 -0400 Subject: [PATCH] bump storj.io/common to latest and storj.io/drpc to v0.0.11 Change-Id: I7a6e823b441eeff4621dfdf2d6577be76c9761c8 --- certificate/peer.go | 4 ++- go.mod | 6 ++-- go.sum | 17 ++++++++++ pkg/server/server.go | 20 +++++++---- private/testplanet/referralmanager.go | 4 ++- satellite/api.go | 44 ++++++++++++++++++------- storagenode/peer.go | 16 ++++++--- storagenode/preflight/localtime_test.go | 6 ++-- 8 files changed, 89 insertions(+), 28 deletions(-) diff --git a/certificate/peer.go b/certificate/peer.go index 123ee45be..e82cb94ee 100644 --- a/certificate/peer.go +++ b/certificate/peer.go @@ -88,7 +88,9 @@ func New(log *zap.Logger, ident *identity.FullIdentity, ca *identity.FullCertifi peer.Certificate.Endpoint = NewEndpoint(log.Named("certificate"), ca, authorizationDB, uint16(config.MinDifficulty)) pbgrpc.RegisterCertificatesServer(peer.Server.GRPC(), peer.Certificate.Endpoint) - pb.DRPCRegisterCertificates(peer.Server.DRPC(), peer.Certificate.Endpoint) + if err := pb.DRPCRegisterCertificates(peer.Server.DRPC(), peer.Certificate.Endpoint); err != nil { + return nil, Error.Wrap(errs.Combine(err, peer.Close())) + } var err error peer.Authorization.Listener, err = net.Listen("tcp", config.AuthorizationAddr) diff --git a/go.mod b/go.mod index d37f8ecf5..ed5abdb61 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/spf13/cobra v0.0.6 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.4.0 - github.com/stretchr/testify v1.4.0 + github.com/stretchr/testify v1.5.1 github.com/stripe/stripe-go v63.1.1+incompatible github.com/vivint/infectious v0.0.0-20190108171102-2455b059135b github.com/zeebo/errs v1.2.2 @@ -41,8 +41,8 @@ require ( golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 golang.org/x/time v0.0.0-20191024005414-555d28b269f0 google.golang.org/grpc v1.27.1 - storj.io/common v0.0.0-20200323134045-2bd4d6e2dd7d - storj.io/drpc v0.0.8 + storj.io/common v0.0.0-20200324171116-bad40c947e25 + storj.io/drpc v0.0.11 storj.io/private v0.0.0-20200323175212-c3ef21e873a9 storj.io/uplink v1.0.0 ) diff --git a/go.sum b/go.sum index 10ddc18e8..b933c6278 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,7 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 h1:45bxf7AZMw github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis/v2 v2.11.1 h1:wuZ/ZHHELZ8DUF5sahK2T6V4Do2SdyKHnjrl/opkP8w= github.com/alicebob/miniredis/v2 v2.11.1/go.mod h1:UA48pmi7aSazcGAvcdKcBB49z521IC9VjTTRz2nIaJE= +github.com/apache/thrift v0.12.0 h1:pODnxUFNcjP9UTLZGTdeh+j16A8lJbRvD3rOtrk/7bs= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -73,6 +74,7 @@ github.com/cloudfoundry/gosigar v1.1.0/go.mod h1:3qLfc2GlfmwOx2+ZDaRGH3Y9fwQ0sQe github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/containerd/containerd v1.2.7 h1:8lqLbl7u1j3MmiL9cJ/O275crSq7bfwUayvvatEupQk= github.com/containerd/containerd v1.2.7/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -273,6 +275,7 @@ github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2i github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -280,6 +283,8 @@ github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -345,6 +350,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stripe/stripe-go v63.1.1+incompatible h1:OpGp55VzHcnu5O/MtVVU42xS2xeAWosx3xELvuoMMMw= github.com/stripe/stripe-go v63.1.1+incompatible/go.mod h1:A1dQZmO/QypXmsL0T8axYZkSN/uA/T/A64pfKdBAMiY= github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -454,6 +461,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -575,6 +584,8 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/spacemonkeygo/monkit-zipkin.v2 v2.0.0-20190419051645-ef9e56ba1633/go.mod h1:pEbh8z/a1Jj9ZHhVsVhLfCZJKE/DVv3twibVY47FWPs= +gopkg.in/spacemonkeygo/monkit.v2 v2.0.0-20180827161543-6ebf5a752f9b/go.mod h1:6UQdi0rNB4YDNwVYP8fJNmjLNaU8MA84WCdXStx3Spo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= @@ -596,9 +607,15 @@ storj.io/common v0.0.0-20200318103328-b7e942ff9304 h1:KQ1ITzbT32bAyBx5gPYQFkMs86 storj.io/common v0.0.0-20200318103328-b7e942ff9304/go.mod h1:I0QTs7z1rI+ZEN95GGY2LKMzP5OZqu0Udga3WhyQfO0= storj.io/common v0.0.0-20200323134045-2bd4d6e2dd7d h1:R4qel+wubcKJP8HvWromOGOplbAlpVNwfIkDkFD4RY0= storj.io/common v0.0.0-20200323134045-2bd4d6e2dd7d/go.mod h1:I0QTs7z1rI+ZEN95GGY2LKMzP5OZqu0Udga3WhyQfO0= +storj.io/common v0.0.0-20200324171116-bad40c947e25 h1:AU4vRaFLkATRaCN6cZY0MiyNdl1n3aRkkEn/1mEo3Sc= +storj.io/common v0.0.0-20200324171116-bad40c947e25/go.mod h1:RBaNRmk/lqyZ7h1MAH4N9zld0z+tO4M9sLOFT30K+cE= storj.io/drpc v0.0.7-0.20191115031725-2171c57838d2/go.mod h1:/ascUDbzNAv0A3Jj7wUIKFBH2JdJ2uJIBO/b9+2yHgQ= storj.io/drpc v0.0.8 h1:wu68cMmtoT0vSWIAZz29RpJkWdi4o0S8BIrLslpH5FQ= storj.io/drpc v0.0.8/go.mod h1:v39uWro/EbXXk+gNnrM9FQuVVS2zUBWBfeduydgeXUA= +storj.io/drpc v0.0.11 h1:6vLxfpSbwCLtqzAoXzXx/SxBqBtbzbmquXPqfcWKqfw= +storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw= +storj.io/monkit-jaeger v0.0.0-20200305222653-48145d285891 h1:8kEmGLyH6HtU+f/Kt9sDLZ9kY1UK1i29YhFI+qr8/NI= +storj.io/monkit-jaeger v0.0.0-20200305222653-48145d285891/go.mod h1:a018CXJ7hJPKYsMDyrdxwsYe1cq8w6691nSwNK5J5Ls= storj.io/private v0.0.0-20200323175212-c3ef21e873a9 h1:dFwvi7xBYIHpqmpfLddibHpXexiN4gaAN1uo4Xx5890= storj.io/private v0.0.0-20200323175212-c3ef21e873a9/go.mod h1:I09FR2ZU1Dy1vaQ2SkUbfGpwVtJrwafjYWGw8W808WE= storj.io/uplink v1.0.0 h1:2tj09e88/2CuGMguS9qyVIEPX2NDE4W/1vMf4bdUCyA= diff --git a/pkg/server/server.go b/pkg/server/server.go index ba2d3f19f..db29ea0e1 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -17,6 +17,7 @@ import ( "storj.io/common/identity" "storj.io/common/peertls/tlsopts" "storj.io/common/rpc" + "storj.io/drpc/drpcmux" "storj.io/drpc/drpcserver" "storj.io/storj/pkg/listenmux" "storj.io/storj/private/grpctlsopts" @@ -34,12 +35,14 @@ type public struct { listener net.Listener drpc *drpcserver.Server grpc *grpc.Server + mux *drpcmux.Mux } type private struct { listener net.Listener drpc *drpcserver.Server grpc *grpc.Server + mux *drpcmux.Mux } // Server represents a bundle of services defined by a specific ID. @@ -78,24 +81,29 @@ func New(log *zap.Logger, tlsOptions *tlsopts.Options, publicAddr, privateAddr s if err != nil { return nil, err } + + publicMux := drpcmux.New() server.public = public{ listener: wrapListener(publicListener), - drpc: drpcserver.NewWithOptions(serverOptions), + drpc: drpcserver.NewWithOptions(publicMux, serverOptions), grpc: grpc.NewServer( grpc.StreamInterceptor(server.logOnErrorStreamInterceptor), grpc.UnaryInterceptor(unaryInterceptor), grpctlsopts.ServerOption(tlsOptions), ), + mux: publicMux, } privateListener, err := net.Listen("tcp", privateAddr) if err != nil { return nil, errs.Combine(err, publicListener.Close()) } + privateMux := drpcmux.New() server.private = private{ listener: wrapListener(privateListener), - drpc: drpcserver.NewWithOptions(serverOptions), + drpc: drpcserver.NewWithOptions(privateMux, serverOptions), grpc: grpc.NewServer(), + mux: privateMux, } return server, nil @@ -113,14 +121,14 @@ func (p *Server) PrivateAddr() net.Addr { return p.private.listener.Addr() } // GRPC returns the server's gRPC handle for registration purposes func (p *Server) GRPC() *grpc.Server { return p.public.grpc } -// DRPC returns the server's dRPC handle for registration purposes -func (p *Server) DRPC() *drpcserver.Server { return p.public.drpc } +// DRPC returns the server's dRPC mux for registration purposes +func (p *Server) DRPC() *drpcmux.Mux { return p.public.mux } // PrivateGRPC returns the server's gRPC handle for registration purposes func (p *Server) PrivateGRPC() *grpc.Server { return p.private.grpc } -// PrivateDRPC returns the server's dRPC handle for registration purposes -func (p *Server) PrivateDRPC() *drpcserver.Server { return p.private.drpc } +// PrivateDRPC returns the server's dRPC mux for registration purposes +func (p *Server) PrivateDRPC() *drpcmux.Mux { return p.private.mux } // Close shuts down the server func (p *Server) Close() error { diff --git a/private/testplanet/referralmanager.go b/private/testplanet/referralmanager.go index 908cfdcd0..8bc77254c 100644 --- a/private/testplanet/referralmanager.go +++ b/private/testplanet/referralmanager.go @@ -67,7 +67,9 @@ func (planet *Planet) newReferralManager() (*server.Server, error) { if err != nil { return nil, err } - pb.DRPCRegisterReferralManager(referralmanager.DRPC(), endpoints) + if err := pb.DRPCRegisterReferralManager(referralmanager.DRPC(), endpoints); err != nil { + return nil, err + } log.Debug("id=" + identity.ID.String() + " addr=" + referralmanager.Addr().String()) return referralmanager, nil diff --git a/satellite/api.go b/satellite/api.go index 3ba69cd0a..367aaef89 100644 --- a/satellite/api.go +++ b/satellite/api.go @@ -260,7 +260,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, peer.Overlay.Inspector = overlay.NewInspector(peer.Overlay.Service) pbgrpc.RegisterOverlayInspectorServer(peer.Server.PrivateGRPC(), peer.Overlay.Inspector) - pb.DRPCRegisterOverlayInspector(peer.Server.PrivateDRPC(), peer.Overlay.Inspector) + if err := pb.DRPCRegisterOverlayInspector(peer.Server.PrivateDRPC(), peer.Overlay.Inspector); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup contact service @@ -287,7 +289,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, peer.Contact.Service = contact.NewService(peer.Log.Named("contact:service"), self, peer.Overlay.Service, peer.DB.PeerIdentities(), peer.Dialer) peer.Contact.Endpoint = contact.NewEndpoint(peer.Log.Named("contact:endpoint"), peer.Contact.Service) pbgrpc.RegisterNodeServer(peer.Server.GRPC(), peer.Contact.Endpoint) - pb.DRPCRegisterNode(peer.Server.DRPC(), peer.Contact.Endpoint) + if err := pb.DRPCRegisterNode(peer.Server.DRPC(), peer.Contact.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } peer.Services.Add(lifecycle.Item{ Name: "contact:service", @@ -297,7 +301,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, { // setup vouchers pbgrpc.RegisterVouchersServer(peer.Server.GRPC(), peer.Vouchers.Endpoint) - pb.DRPCRegisterVouchers(peer.Server.DRPC(), peer.Vouchers.Endpoint) + if err := pb.DRPCRegisterVouchers(peer.Server.DRPC(), peer.Vouchers.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup live accounting @@ -344,7 +350,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, config.Orders.NodeStatusLogging, ) pbgrpc.RegisterOrdersServer(peer.Server.GRPC(), peer.Orders.Endpoint) - pb.DRPCRegisterOrders(peer.Server.DRPC(), peer.Orders.Endpoint.DRPC()) + if err := pb.DRPCRegisterOrders(peer.Server.DRPC(), peer.Orders.Endpoint.DRPC()); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup marketing portal @@ -420,7 +428,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, config.Metainfo.RateLimiter, ) pbgrpc.RegisterMetainfoServer(peer.Server.GRPC(), peer.Metainfo.Endpoint2) - pb.DRPCRegisterMetainfo(peer.Server.DRPC(), peer.Metainfo.Endpoint2) + if err := pb.DRPCRegisterMetainfo(peer.Server.DRPC(), peer.Metainfo.Endpoint2); err != nil { + return nil, errs.Combine(err, peer.Close()) + } peer.Services.Add(lifecycle.Item{ Name: "metainfo:endpoint", @@ -431,7 +441,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, { // setup datarepair peer.Repair.Inspector = irreparable.NewInspector(peer.DB.Irreparable()) pbgrpc.RegisterIrreparableInspectorServer(peer.Server.PrivateGRPC(), peer.Repair.Inspector) - pb.DRPCRegisterIrreparableInspector(peer.Server.PrivateDRPC(), peer.Repair.Inspector) + if err := pb.DRPCRegisterIrreparableInspector(peer.Server.PrivateDRPC(), peer.Repair.Inspector); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup inspector @@ -441,7 +453,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, peer.Metainfo.Service, ) pbgrpc.RegisterHealthInspectorServer(peer.Server.PrivateGRPC(), peer.Inspector.Endpoint) - pb.DRPCRegisterHealthInspector(peer.Server.PrivateDRPC(), peer.Inspector.Endpoint) + if err := pb.DRPCRegisterHealthInspector(peer.Server.PrivateDRPC(), peer.Inspector.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup mailservice @@ -550,7 +564,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, pc.StripeCoinPayments.ConversionRatesCycleInterval) pbgrpc.RegisterPaymentsServer(peer.Server.PrivateGRPC(), peer.Payments.Inspector) - pb.DRPCRegisterPayments(peer.Server.PrivateDRPC(), peer.Payments.Inspector) + if err := pb.DRPCRegisterPayments(peer.Server.PrivateDRPC(), peer.Payments.Inspector); err != nil { + return nil, errs.Combine(err, peer.Close()) + } peer.Services.Add(lifecycle.Item{ Name: "payments.stripe:version", @@ -619,7 +635,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, peer.DB.StoragenodeAccounting(), ) pbgrpc.RegisterNodeStatsServer(peer.Server.GRPC(), peer.NodeStats.Endpoint) - pb.DRPCRegisterNodeStats(peer.Server.DRPC(), peer.NodeStats.Endpoint) + if err := pb.DRPCRegisterNodeStats(peer.Server.DRPC(), peer.NodeStats.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup heldamount endpoint @@ -633,7 +651,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, peer.Overlay.DB, peer.HeldAmount.Service) pbgrpc.RegisterHeldAmountServer(peer.Server.GRPC(), peer.HeldAmount.Endpoint) - pb.DRPCRegisterHeldAmount(peer.Server.DRPC(), peer.HeldAmount.Endpoint) + if err := pb.DRPCRegisterHeldAmount(peer.Server.DRPC(), peer.HeldAmount.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup graceful exit @@ -650,7 +670,9 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, config.GracefulExit) pbgrpc.RegisterSatelliteGracefulExitServer(peer.Server.GRPC(), peer.GracefulExit.Endpoint) - pb.DRPCRegisterSatelliteGracefulExit(peer.Server.DRPC(), peer.GracefulExit.Endpoint.DRPC()) + if err := pb.DRPCRegisterSatelliteGracefulExit(peer.Server.DRPC(), peer.GracefulExit.Endpoint.DRPC()); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } else { peer.Log.Named("gracefulexit").Info("disabled") } diff --git a/storagenode/peer.go b/storagenode/peer.go index 5ad5b3197..c4ebbe191 100644 --- a/storagenode/peer.go +++ b/storagenode/peer.go @@ -368,7 +368,9 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten peer.Contact.Endpoint = contact.NewEndpoint(peer.Log.Named("contact:endpoint"), peer.Contact.PingStats) pbgrpc.RegisterContactServer(peer.Server.GRPC(), peer.Contact.Endpoint) - pb.DRPCRegisterContact(peer.Server.DRPC(), peer.Contact.Endpoint) + if err := pb.DRPCRegisterContact(peer.Server.DRPC(), peer.Contact.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } @@ -457,7 +459,9 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten } pbgrpc.RegisterPiecestoreServer(peer.Server.GRPC(), peer.Storage2.Endpoint) - pb.DRPCRegisterPiecestore(peer.Server.DRPC(), peer.Storage2.Endpoint.DRPC()) + if err := pb.DRPCRegisterPiecestore(peer.Server.DRPC(), peer.Storage2.Endpoint.DRPC()); err != nil { + return nil, errs.Combine(err, peer.Close()) + } // TODO workaround for custom timeout for order sending request (read/write) sc := config.Server @@ -584,7 +588,9 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten config.Contact.ExternalAddress, ) pbgrpc.RegisterPieceStoreInspectorServer(peer.Server.PrivateGRPC(), peer.Storage2.Inspector) - pb.DRPCRegisterPieceStoreInspector(peer.Server.PrivateDRPC(), peer.Storage2.Inspector) + if err := pb.DRPCRegisterPieceStoreInspector(peer.Server.PrivateDRPC(), peer.Storage2.Inspector); err != nil { + return nil, errs.Combine(err, peer.Close()) + } } { // setup graceful exit service @@ -595,7 +601,9 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten peer.Storage2.BlobsCache, ) pbgrpc.RegisterNodeGracefulExitServer(peer.Server.PrivateGRPC(), peer.GracefulExit.Endpoint) - pb.DRPCRegisterNodeGracefulExit(peer.Server.PrivateDRPC(), peer.GracefulExit.Endpoint) + if err := pb.DRPCRegisterNodeGracefulExit(peer.Server.PrivateDRPC(), peer.GracefulExit.Endpoint); err != nil { + return nil, errs.Combine(err, peer.Close()) + } peer.GracefulExit.Chore = gracefulexit.NewChore( peer.Log.Named("gracefulexit:chore"), diff --git a/storagenode/preflight/localtime_test.go b/storagenode/preflight/localtime_test.go index d4985e663..a901aa33a 100644 --- a/storagenode/preflight/localtime_test.go +++ b/storagenode/preflight/localtime_test.go @@ -81,9 +81,10 @@ func TestLocalTime_OutOfSync(t *testing.T) { require.NoError(t, err) defer ctx.Check(contactServer.Close) - pb.DRPCRegisterNode(contactServer.DRPC(), &mockServer{ + err = pb.DRPCRegisterNode(contactServer.DRPC(), &mockServer{ localTime: time.Now().Add(-25 * time.Minute), }) + require.NoError(t, err) group.Go(func() error { return contactServer.Run(ctx) @@ -136,9 +137,10 @@ func TestLocalTime_OutOfSync(t *testing.T) { require.NoError(t, err) defer ctx.Check(contactServer.Close) - pb.DRPCRegisterNode(contactServer.DRPC(), &mockServer{ + err = pb.DRPCRegisterNode(contactServer.DRPC(), &mockServer{ localTime: time.Now().Add(-31 * time.Minute), }) + require.NoError(t, err) group.Go(func() error { return contactServer.Run(ctx)