feat(audit,install): #1030 audit overflow drops exported as otopcua.audit.dropped; scripted SCM-restart-after-cluster-exit gate

- AuditWriterActor: every buffer-full drop is added to OtOpcUaTelemetry.AuditDropped
  (otopcua.audit.dropped{reason=buffer_full, actor}) — the count used to be readable only
  through the actor's own property.
- scripts/install/tests/Test-ScmRestartAfterClusterExit.Windows.ps1: the windev manual gate
  of 2026-12-03 as a script (qfailure restart action; failover/command trigger => non-zero exit,
  7031, Running under a new pid; Stop-Service stays stopped; optional kill control). Parse-checked
  with pwsh on macOS; must be run elevated on a Windows box hosting OtOpcUaHost.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-12-03 15:02:09 -05:00
parent 6b19f4add6
commit 2a8bac5bf5
7 changed files with 266 additions and 2 deletions
+1 -1
View File
@@ -435,7 +435,7 @@ per cluster at `/clusters/{id}/audit`. It has no `appsettings` section — it is
has a `ConfigDb` — but one schema property is worth recording here because it constrains how callers may
write to it:
*Flush behaviour (#980 / review 05 H-2):* `AuditWriterActor` batches events and flushes every 5 s (or at 500). A flush that fails because the database did not answer **keeps** the batch and retries on the next tick; the buffer is bounded at 10 000 events (drop-oldest, with `OverflowDroppedCount` and a Warning). Rows the database rejects outright (e.g. a duplicate `EventId`) are still dropped individually. Events are lost only if the actor stops while the database is still down (logged at Error with the count).
*Flush behaviour (#980 / review 05 H-2):* `AuditWriterActor` batches events and flushes every 5 s (or at 500). A flush that fails because the database did not answer **keeps** the batch and retries on the next tick; the buffer is bounded at 10 000 events (drop-oldest, with `OverflowDroppedCount` and a Warning; since #1030 every drop is also exported as the meter counter `otopcua.audit.dropped{reason=buffer_full}` on the `ZB.MOM.WW.OtOpcUa` meter — alert on any non-zero rate, it means `ConfigAuditLog` is missing rows). Rows the database rejects outright (e.g. a duplicate `EventId`) are still dropped individually. Events are lost only if the actor stops while the database is still down (logged at Error with the count).
- **`EventId` gives cross-restart deduplication, and the DB enforces it.** Each row carries the
stable per-event `AuditEvent.EventId`, under a *filtered* unique index
+9
View File
@@ -504,6 +504,15 @@ two-node pair that choice means *any* crash of the oldest node is a full outage.
that Akka's -1 is invisible to SCM recovery). Positive control: `sc stop` on the fixed build → clean
`Stopped`, exit 0, no recovery. Under `auto-down` the *survivor* no longer needs this (it is never the one
downed); the **downed** node still does.
**Scripted form of that gate (#1030):** `scripts/install/tests/Test-ScmRestartAfterClusterExit.Windows.ps1`, run
elevated on the box hosting an installed `OtOpcUaHost` (the pair's current Primary for the default
`-Trigger Failover`, which pauses while the operator presses *Trigger failover* on the cluster redundancy page;
`-Trigger Command -TriggerCommand '…'` for an unattended trigger). It checks `sc.exe qfailure` has a restart action,
that the leave ends the process non-zero, logs **7031** and comes back `Running` under a new pid, and — as the
negative control — that `Stop-Service` stays `Stopped` with no 7031; `-KillControl` adds a hard-kill leg that
proves the SCM recovery config on its own. It never reconfigures the service and always leaves it running. Not
for the wonder boxes while remote access is on hold.
3. **Both peers listed in `SeedNodes`** on every node, **each node listing itself first**, so a restarted
node can re-join via either peer and a node cold-starting while its peer is dead still forms the
cluster. Without the self-first ordering it waits in `InitJoin` forever (auto-down removes the crash
+3
View File
@@ -186,6 +186,9 @@ steps inside the window (a `data\` backup) and the host start-up to `/health/rea
- `scripts/install/Install-Services.ps1 -Roles admin,driver` — installs `OtOpcUaHost`.
- `scripts/install/Install-ScriptWorkerIsolation.ps1` — the ScriptWorker identity, ACLs and firewall rule (above); only for `Scripting:Runner` ≠ `InProcess`.
- `scripts/install/Invoke-OtOpcUaInstallSwap.ps1` — upgrade/rollback folder swap with the isolation `-Reapply` + `-Verify` gate built in (lmxopcua#901), scoped so only the swapped-in folder is handled while the service is stopped (lmxopcua#905, above).
- `scripts/install/tests/Test-ScmRestartAfterClusterExit.Windows.ps1` — elevated, on the node's own box: checks that a node
leaving its cluster (manual failover) is restarted by the `sc.exe failure` recovery `Install-Services.ps1` sets, and that a
clean `Stop-Service` is not (#980/#1030; `docs/Redundancy.md` §"Recovery still depends on supervision").
- `scripts/install/Uninstall-Services.ps1` — stops + removes the host service. (The historian backend is the external HistorianGateway — not installed/removed by these scripts.)
## Logging