From 208d150500e652478ab8332c8493f506f8e620a2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 20 Oct 2021 17:28:37 +0300 Subject: [PATCH] [#937] node: Init node state before gRPC server start Fix panic when node processes RPC requests before state initialization is finished. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 3 +++ cmd/neofs-node/netmap.go | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e24822d1..dfb69e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Changelog for NeoFS Node ## [Unreleased] +### Fixed +- Storage Node handles requests before its initialization is finished (#934) + ## [0.26.0] - 2021-10-19 - Udo (우도, 牛島) NeoFS API v2.10 support diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 628162fe..88c372b2 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -90,6 +90,8 @@ func initNetmapService(c *cfg) { initMorphComponents(c) } + initNetmapState(c) + server := netmapTransportGRPC.New( netmapService.NewSignService( &c.key.PrivateKey, @@ -162,9 +164,9 @@ func initNetmapService(c *cfg) { } } +// bootstrapNode adds current node to the Network map. +// Must be called after initNetmapService. func bootstrapNode(c *cfg) { - initState(c) - if c.needBootstrap() { err := c.bootstrap() fatalOnErrDetails("bootstrap error", err) @@ -191,7 +193,9 @@ func setNetmapNotificationParser(c *cfg, sTyp string, p event.NotificationParser c.cfgNetmap.parsers[typ] = p } -func initState(c *cfg) { +// initNetmapState inits current Network map state. +// Must be called after Morph components initialization. +func initNetmapState(c *cfg) { epoch, err := c.cfgNetmap.wrapper.Epoch() fatalOnErrDetails("could not initialize current epoch number", err)