[management] Add Redis-backed kill switch for Sync fast path

Gate the peer-sync fast path on a runtime flag polled from Redis so operators can roll the optimisation out gradually and flip it off without a redeploy.

Without NB_PEER_SYNC_REDIS_ADDRESS the routine stays disabled, every Sync runs the full network map path, and no entries accumulate in the peer serial cache — bit-for-bit identical to the pre-fast-path behaviour. When the env var is set, a background goroutine polls the configured key (default "peerSyncFastPath") every minute; values "1" or "true" enable the fast path, anything else disables it.

- RunFastPathFlagRoutine mirrors shared/logleveloverrider: dedicated Redis connection, background ticker, redis.Nil treated as disabled.
- NewServer takes the flag handle; tryFastPathSync and the recordPeerSyncEntry helpers short-circuit when Enabled() is false.
- invalidatePeerSyncEntry still runs on Login regardless of flag state.
- NewFastPathFlag(bool) exposed for tests and callers that need to force a state without going through Redis.
This commit is contained in:
mlsmaycon
2026-04-21 15:52:34 +02:00
parent 3f4ef0031b
commit 8430b06f2a
11 changed files with 345 additions and 9 deletions
+2 -1
View File
@@ -392,7 +392,8 @@ func startManagementForTest(t *testing.T, testFile string, config *config.Config
}
peerSerialCache := nbgrpc.NewPeerSerialCache(ctx, cacheStore, time.Minute)
mgmtServer, err := nbgrpc.NewServer(config, accountManager, settingsMockManager, jobManager, secretsManager, nil, nil, MockIntegratedValidator{}, networkMapController, nil, peerSerialCache)
fastPathFlag := nbgrpc.NewFastPathFlag(true)
mgmtServer, err := nbgrpc.NewServer(config, accountManager, settingsMockManager, jobManager, secretsManager, nil, nil, MockIntegratedValidator{}, networkMapController, nil, peerSerialCache, fastPathFlag)
if err != nil {
return nil, nil, "", cleanup, err
}
+1
View File
@@ -257,6 +257,7 @@ func startServer(
networkMapController,
nil,
nil,
nil,
)
if err != nil {
t.Fatalf("failed creating management server: %v", err)