[#1893] neofs-node: Do not fail unless all gRPC endpoints are unavailable
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
1e6588e761
commit
280e56f4bb
3 changed files with 25 additions and 7 deletions
|
@ -26,6 +26,7 @@ Changelog for NeoFS Node
|
|||
- `neofs-adm` now works correctly with a committee of more than 4 nodes (#1949, #1959)
|
||||
- Closing a shard now waits until GC background workers stop (#1964)
|
||||
- Make it possible to use `shard.ContainerSize` in read-only mode (#1975)
|
||||
- Storage node now starts if at least one gRPC enpoint is available (#1893)
|
||||
|
||||
### Removed
|
||||
### Updated
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/tree"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
@ -50,7 +51,10 @@ func initControlService(c *cfg) {
|
|||
)
|
||||
|
||||
lis, err := net.Listen("tcp", endpoint)
|
||||
fatalOnErr(err)
|
||||
if err != nil {
|
||||
c.log.Error("can't listen gRPC endpoint (control)", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
c.cfgControlService.server = grpc.NewServer()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
@ -14,12 +15,8 @@ import (
|
|||
)
|
||||
|
||||
func initGRPC(c *cfg) {
|
||||
var successCount int
|
||||
grpcconfig.IterateEndpoints(c.appCfg, func(sc *grpcconfig.Config) {
|
||||
lis, err := net.Listen("tcp", sc.Endpoint())
|
||||
fatalOnErr(err)
|
||||
|
||||
c.cfgGRPC.listeners = append(c.cfgGRPC.listeners, lis)
|
||||
|
||||
serverOpts := []grpc.ServerOption{
|
||||
grpc.MaxSendMsgSize(maxMsgSize),
|
||||
}
|
||||
|
@ -28,7 +25,10 @@ func initGRPC(c *cfg) {
|
|||
|
||||
if tlsCfg != nil {
|
||||
cert, err := tls.LoadX509KeyPair(tlsCfg.CertificateFile(), tlsCfg.KeyFile())
|
||||
fatalOnErrDetails("could not read certificate from file", err)
|
||||
if err != nil {
|
||||
c.log.Error("could not read certificate from file", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
var cipherSuites []uint16
|
||||
if !tlsCfg.UseInsecureCrypto() {
|
||||
|
@ -54,6 +54,14 @@ func initGRPC(c *cfg) {
|
|||
serverOpts = append(serverOpts, grpc.Creds(creds))
|
||||
}
|
||||
|
||||
lis, err := net.Listen("tcp", sc.Endpoint())
|
||||
if err != nil {
|
||||
c.log.Error("can't listen gRPC endpoint", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
c.cfgGRPC.listeners = append(c.cfgGRPC.listeners, lis)
|
||||
|
||||
srv := grpc.NewServer(serverOpts...)
|
||||
|
||||
c.onShutdown(func() {
|
||||
|
@ -61,7 +69,12 @@ func initGRPC(c *cfg) {
|
|||
})
|
||||
|
||||
c.cfgGRPC.servers = append(c.cfgGRPC.servers, srv)
|
||||
successCount++
|
||||
})
|
||||
|
||||
if successCount == 0 {
|
||||
fatalOnErr(errors.New("could not listen to any gRPC endpoints"))
|
||||
}
|
||||
}
|
||||
|
||||
func serveGRPC(c *cfg) {
|
||||
|
|
Loading…
Reference in a new issue