fix(adminui): /hosts eviction keys on authored + DEPLOYED drivers (review D-b r1 I1)
Staleness is not a liveness proof: DriverInstanceActor publishes on a 30 s tick and dedups on a health fingerprint, so a running Faulted, idle or tagless driver deleted in /raw (undeployed) went stale and was evicted. DeployedDriverSet reads, per node, the latest and latest-Applied NodeDeploymentState deployments plus the latest Sealed one, parses each artifact's DriverInstances once (cached by deployment id, pruned to the live set, only the blob column of an uncached row is read), and /hosts unions it with the authored set. The staleness clause stays as a second guard. An unreadable artifact or a failed read means 'unknown' and skips eviction. The Hosts.razor comment claiming '~12 health publishes' is corrected. N-new-2: the CSV download's Content-Disposition carries an RFC 5987 filename* via ContentDispositionHeaderValue.SetHttpFileName. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
@inject IDriverStatusSnapshotStore DriverStore
|
||||
@inject IDriverResilienceStatusStore ResilienceStore
|
||||
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
|
||||
@inject DeployedDriverSet Deployed
|
||||
@inject Microsoft.Extensions.Logging.ILogger<Hosts> Logger
|
||||
@implements IAsyncDisposable
|
||||
|
||||
@@ -329,7 +330,10 @@ else
|
||||
@code {
|
||||
private const int RefreshIntervalSeconds = 5;
|
||||
|
||||
// An unconfigured driver's snapshot must be this old before eviction (≈ 12 health publishes).
|
||||
// Second guard only: a snapshot of a driver neither authored nor deployed must also be this old before it
|
||||
// is evicted. NOT a liveness proof — DriverInstanceActor publishes on a 30 s tick and dedups on a health
|
||||
// fingerprint, so a running Faulted/idle/tagless driver can go hours without publishing; the deployed
|
||||
// set (DeployedDriverSet) is what keeps such a driver's row.
|
||||
private static readonly TimeSpan EvictUnconfiguredAfter = TimeSpan.FromSeconds(60);
|
||||
|
||||
private List<MemberRow>? _rows;
|
||||
@@ -447,19 +451,26 @@ else
|
||||
.Select(d => new HostsDriverInstanceInfo(d.DriverInstanceId, d.ClusterId, d.Name, d.DriverType, d.Enabled))
|
||||
.ToListAsync(_cts.Token);
|
||||
|
||||
// Evict snapshots of driver instances that are no longer configured (deleted, or re-created
|
||||
// under a new id) AND have stopped publishing. The stores have no other removal path, so
|
||||
// without this a removed driver stays on this page as a frozen row until the admin node
|
||||
// restarts. DriverInstances is the AUTHORED table: a driver deleted in /raw keeps running (and
|
||||
// publishing every few seconds) until the next deploy, so staleness is what proves it stopped.
|
||||
// Evict snapshots of driver instances that are neither AUTHORED nor DEPLOYED, and stale. The
|
||||
// stores have no other removal path, so without this a removed driver stays on this page as a
|
||||
// frozen row until the admin node restarts. DriverInstances is the authored (draft) table: a
|
||||
// driver deleted in /raw keeps running until the next deploy, and a quiet one (Faulted, idle,
|
||||
// tagless) may not publish at all meanwhile, so the deployed set — not staleness — is what keeps
|
||||
// it (review D-b r1, I1). Unknown deployed set ⇒ no eviction this sweep.
|
||||
// Only a SUCCESSFUL load reaches here; the failure path below blanks _instances and must
|
||||
// never sweep the stores.
|
||||
var configured = _instances
|
||||
.Select(i => i.DriverInstanceId)
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
var staleBefore = DateTime.UtcNow - EvictUnconfiguredAfter;
|
||||
var evicted = DriverStore.EvictUnconfiguredStale(configured, staleBefore);
|
||||
ResilienceStore.EvictUnconfiguredStale(configured, staleBefore);
|
||||
var evicted = 0;
|
||||
var deployed = await Deployed.LoadAsync(_cts.Token);
|
||||
if (deployed is not null)
|
||||
{
|
||||
var configured = _instances
|
||||
.Select(i => i.DriverInstanceId)
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
configured.UnionWith(deployed);
|
||||
var staleBefore = DateTime.UtcNow - EvictUnconfiguredAfter;
|
||||
evicted = DriverStore.EvictUnconfiguredStale(configured, staleBefore);
|
||||
ResilienceStore.EvictUnconfiguredStale(configured, staleBefore);
|
||||
}
|
||||
|
||||
return evicted > 0
|
||||
|| !_nodes.SequenceEqual(previousNodes)
|
||||
|
||||
Reference in New Issue
Block a user