fix(health): evict deleted sites from the aggregator on the periodic site refresh
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user