Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog for NeoFS Node
- `neofs-lens meta resync` command (#3849)
- `policer.boost_multiplier` SN config option (#3855)
- `neofs-lens storage flush-write-caches` command (#3872)
- Reload gRPC SN config with SIGHUP (#3874)

### Fixed
- Resending the header after chunks have already been sent in object service `Get` handler (#3833)
Expand Down
5 changes: 3 additions & 2 deletions cmd/neofs-node/accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
accountingService "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
protoaccounting "github.com/nspcc-dev/neofs-sdk-go/proto/accounting"
"google.golang.org/grpc"
)

func initAccountingService(c *cfg) {
Expand All @@ -12,7 +13,7 @@ func initAccountingService(c *cfg) {

server := accountingService.New(&c.key.PrivateKey, c.networkState, c.bCli)

for _, srv := range c.cfgGRPC.servers {
c.cfgGRPC.registerService(func(srv *grpc.Server) {
protoaccounting.RegisterAccountingServiceServer(srv, server)
}
})
}
27 changes: 26 additions & 1 deletion cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,26 @@ func (c *cfg) GetNetworkMap() (netmap.NetMap, error) {
func (c *cfg) CurrentEpoch() uint64 { return c.networkState.CurrentEpoch() }

type cfgGRPC struct {
mu sync.Mutex

listeners []net.Listener
servers []*grpc.Server

// serviceRegistrators stores functions that register gRPC service
// implementations into a gRPC server.
serviceRegistrators []func(*grpc.Server)
}

servers []*grpc.Server
// registerService saves the registrator function and immediately applies it to
// all currently running gRPC servers.
func (g *cfgGRPC) registerService(f func(*grpc.Server)) {
g.mu.Lock()
defer g.mu.Unlock()

g.serviceRegistrators = append(g.serviceRegistrators, f)
for _, srv := range g.servers {
f(srv)
}
}

type cfgMeta struct {
Expand Down Expand Up @@ -681,6 +698,7 @@ func (c *cfg) configWatcher(ctx context.Context) {

oldMetrics := writeMetricConfig(c.appCfg)
oldProfiler := writeProfilerConfig(c.appCfg)
oldGRPC := writeGRPCConfig(c.appCfg)

c.appCfg, err = config.New(config.WithConfigFile(c.appCfg.Path()))
if err != nil {
Expand Down Expand Up @@ -745,6 +763,13 @@ func (c *cfg) configWatcher(ctx context.Context) {
continue
}

// gRPC

if err = reloadGRPC(c, oldGRPC); err != nil {
c.log.Error("gRPC configuration reload", zap.Error(err))
continue
}

c.log.Info("configuration has been reloaded successfully")
case <-ctx.Done():
return
Expand Down
5 changes: 3 additions & 2 deletions cmd/neofs-node/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
protocontainer "github.com/nspcc-dev/neofs-sdk-go/proto/container"
"github.com/nspcc-dev/neofs-sdk-go/user"
"go.uber.org/zap"
"google.golang.org/grpc"
)

func initContainerService(c *cfg) {
Expand Down Expand Up @@ -112,9 +113,9 @@ func initContainerService(c *cfg) {
cnrSrv.ResetSessionTokenCheckCache()
})

for _, srv := range c.cfgGRPC.servers {
c.cfgGRPC.registerService(func(srv *grpc.Server) {
protocontainer.RegisterContainerServiceServer(srv, cnrSrv)
}
})
}

func initSizeLoadReports(c *cfg) {
Expand Down
Loading
Loading