[#1329] tree: Sync tree on startup

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-10-06 23:18:46 +03:00 committed by fyrchik
parent f5f560d903
commit f4a3fa2977
3 changed files with 62 additions and 0 deletions

View file

@ -42,6 +42,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
"github.com/nspcc-dev/neofs-node/pkg/metrics"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmap2 "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
@ -305,6 +306,10 @@ type internals struct {
workers []worker
closers []func()
// onlineStateHandlers are executed in a separate
// goroutine on every !ONLINE -> ONLINE state transition
onlineStateHandlers []func(context.Context)
apiVersion version.Version
healthStatus *atomic.Int32
// is node under maintenance
@ -347,6 +352,8 @@ type shared struct {
netMap atomicstd.Value // type netmap.NetMap
netMapSource netmapCore.Source
cnrClient *containerClient.Client
respSvc *response.Service
replicator *replicator.Replicator
@ -831,6 +838,13 @@ func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) {
// Called with nil when storage node is outside the NeoFS network map
// (before entering the network and after leaving it).
func (c *cfg) handleLocalNodeInfo(ni *netmap.NodeInfo) {
if c.cfgNetmap.state.controlNetmapStatus() != control.NetmapStatus_ONLINE &&
ni != nil && ni.IsOnline() {
for _, h := range c.onlineStateHandlers {
go h(c.ctx)
}
}
c.cfgNetmap.state.setNodeInfo(ni)
}
@ -935,3 +949,7 @@ func (c *cfg) configWatcher(ctx context.Context) {
}
}
}
func (c *cfg) addOnlineStateHandler(h func(ctx context.Context)) {
c.onlineStateHandlers = append(c.onlineStateHandlers, h)
}