fix(health): evict deleted sites from the aggregator on the periodic site refresh

This commit is contained in:
Joseph Doherty
2026-07-08 16:27:38 -04:00
parent 87c7255912
commit d962c77bb7
7 changed files with 99 additions and 3 deletions
@@ -196,6 +196,20 @@ public class CentralHealthAggregator : BackgroundService, ICentralHealthAggregat
return state;
}
/// <inheritdoc />
public void PruneUnknownSites(IReadOnlyCollection<string> knownSiteIds)
{
var known = new HashSet<string>(knownSiteIds, StringComparer.Ordinal);
foreach (var siteId in _siteStates.Keys)
{
if (siteId == CentralHealthReportLoop.CentralSiteId || known.Contains(siteId))
continue;
if (_siteStates.TryRemove(siteId, out _))
_logger.LogInformation(
"Site {SiteId} evicted from health aggregator (no longer configured)", siteId);
}
}
/// <inheritdoc />
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{