From 98da0323249c8f8c3e646371cdc56b36f5b20722 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Thu, 26 Oct 2023 10:36:22 +0300 Subject: [PATCH] [#758] ir: Do not exclude node in maintenance mode from netmap Signed-off-by: Anton Nikiforov --- pkg/innerring/processors/netmap/cleanup_table.go | 5 ++++- .../processors/netmap/cleanup_table_test.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/innerring/processors/netmap/cleanup_table.go b/pkg/innerring/processors/netmap/cleanup_table.go index 80117247d..705e21d99 100644 --- a/pkg/innerring/processors/netmap/cleanup_table.go +++ b/pkg/innerring/processors/netmap/cleanup_table.go @@ -24,6 +24,8 @@ type ( epochStamp binNodeInfo []byte + + maintenance bool } ) @@ -58,6 +60,7 @@ func (c *cleanupTable) update(snapshot netmap.NetMap, now uint64) { } access.binNodeInfo = binNodeInfo + access.maintenance = nmNodes[i].IsMaintenance() newMap[keyString] = access } @@ -105,7 +108,7 @@ func (c *cleanupTable) forEachRemoveCandidate(epoch uint64, f func(string) error defer c.Unlock() for keyString, access := range c.lastAccess { - if epoch-access.epoch > c.threshold { + if !access.maintenance && epoch-access.epoch > c.threshold { access.removeFlag = true // set remove flag c.lastAccess[keyString] = access diff --git a/pkg/innerring/processors/netmap/cleanup_table_test.go b/pkg/innerring/processors/netmap/cleanup_table_test.go index 959710393..ae5620733 100644 --- a/pkg/innerring/processors/netmap/cleanup_table_test.go +++ b/pkg/innerring/processors/netmap/cleanup_table_test.go @@ -124,6 +124,21 @@ func TestCleanupTable(t *testing.T) { })) require.EqualValues(t, len(infos)-1, cnt) }) + + t.Run("skip maintenance nodes", func(t *testing.T) { + cnt := 0 + infos[1].SetMaintenance() + key := netmap.StringifyPublicKey(infos[1]) + c.update(networkMap, 5) + + require.NoError(t, + c.forEachRemoveCandidate(5, func(s string) error { + cnt++ + require.NotEqual(t, s, key) + return nil + })) + require.EqualValues(t, len(infos)-1, cnt) + }) }) }