fix(host): unify active-node on oldest-member semantics — purge/self-report/labels now track the singleton host

This commit is contained in:
Joseph Doherty
2026-07-08 15:48:07 -04:00
parent 6320be9954
commit da6d5ae12c
5 changed files with 70 additions and 21 deletions
@@ -9,9 +9,12 @@ namespace ZB.MOM.WW.ScadaBridge.Host.Health;
/// <see cref="IActiveNodeGate"/> backed by the running Akka.NET cluster.
///
/// The inbound API is "Central cluster only (active node)" — a standby central
/// node must not execute method scripts or <c>Route.To()</c> calls. This gate
/// mirrors the leadership check in <see cref="ActiveNodeHealthCheck"/> (the
/// node is the cluster leader, <see cref="MemberStatus.Up"/>), so
/// node must not execute method scripts or <c>Route.To()</c> calls. Active =
/// the oldest Up member (the singleton host), evaluated by
/// <see cref="ClusterActivityEvaluator.SelfIsOldest(Cluster, string?)"/> — NOT
/// the cluster leader, whose address-ordered definition diverges from singleton
/// placement after a restart (review 01 [High]). This is the same evaluator
/// backing <see cref="OldestNodeActiveHealthCheck"/>, so
/// <see cref="InboundApiEndpointFilter"/> can return HTTP 503 on a standby.
///
/// Registered only in the Central-role branch of <c>Program.cs</c>. The gate
@@ -42,12 +45,7 @@ public sealed class ActiveNodeGate : IActiveNodeGate
return false;
var cluster = Cluster.Get(system);
var self = cluster.SelfMember;
if (self.Status != MemberStatus.Up)
return false;
var leader = cluster.State.Leader;
return leader != null && leader == self.Address;
return ClusterActivityEvaluator.SelfIsOldest(cluster);
}
}
}