fix(galaxy): clear told-active alarms absent from a complete snapshot (#944); handle provider_status/snapshot_status, withhold truncated snapshots (#945)
#944: a snapshot/QueryActiveAlarms lists active alarms only, so a Clear dropped while the host's OnAlarmEvent handler was detached (or the stream was down) was never recovered. The driver records which alarms it delivered as active; on a COMPLETE read (sentinel or re-read, new IGalaxyAlarmFeed.ActiveSetDelivered, raised under the dispatch lock) it synthesises a restatement Clear for told-active alarms of the live subscription the read does not name, before the known-state signal. A re-read counts alarms the live stream restated meanwhile as present. #945: provider_status / snapshot_status no longer fall to the decode-failure default (logged + counters). A snapshot flagged truncated (snapshot_status or per-record flag) is not complete: no sweep, no known-state signal; when the gateway clears the verdict the driver re-reads. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -214,9 +214,13 @@ Every (re)open of `StreamAlarms` replays the gateway's active-alarm snapshot. `G
|
||||
- If a stream (re)opened while the query was in flight, the whole re-read is discarded and does not signal. An alarm that cleared in the reopen gap is simply absent from the new snapshot, so the query's entry for it would be a phantom `Active`. The reopened stream's own sentinel covers the subscription.
|
||||
- A re-read is not started while the current stream has not yet delivered its sentinel.
|
||||
- **Bounded.** One re-read runs at a time. Requests that arrive while it runs collapse into one follow-up run. A failure is retried 3 times, 5 s apart. A gateway without the RPC (`Unimplemented`) is not retried. A re-read that fails never signals: the conditions stay unknown, F5 diagnoses them, and the next stream sentinel signals as before.
|
||||
- **Residuals.** The query can be *ahead* of the stream: it can show a raise whose live `Raise` is still queued. That `Raise` then lands on an already-active condition, and the host treats it as the re-statement it is. Like every snapshot replay, the query lists active alarms only. An alarm that cleared while no subscription was live, so that its live `Clear` was dropped, is not cleared by it. This is a pre-existing limit of every snapshot replay.
|
||||
- **Residuals.** The query can be *ahead* of the stream: it can show a raise whose live `Raise` is still queued. That `Raise` then lands on an already-active condition, and the host treats it as the re-statement it is. Like every snapshot replay, the query lists active alarms only; a `Clear` dropped while no handler was attached is recovered by the sweep below (#944).
|
||||
- **In practice.** A deploy that changes a Galaxy driver's alarm tags also changes its config, so the driver respawns and its fresh feed's first sentinel covers the new set (#665: there is no in-place path). The re-read is the safety net for the paths where the feed outlives the subscription.
|
||||
|
||||
**Clearing alarms a complete snapshot no longer lists (#944).** A snapshot or `QueryActiveAlarms` result lists ACTIVE alarms only, so an alarm whose live `Clear` was dropped (no alarm subscription, or `DriverInstanceActor` had detached its `OnAlarmEvent` handler, or the stream was down) stayed Active on the node after every replay. The driver now keeps, per ConditionId (RawPath), the alarms it last DELIVERED to a handler as active (Raise / Retrigger / ActiveAcknowledged; a delivered Clear removes the entry, a dropped one does not). The feed raises `IGalaxyAlarmFeed.ActiveSetDelivered` for each COMPLETE read: a stream's `snapshot_complete` sentinel (before `SnapshotDelivered`) or a successful re-read. The driver then synthesises a `Clear` (flagged `IsRestatement`) for every told-active alarm of the live subscription that the read does not name, ahead of the known-state signal. Serialisation: the event is raised under the feed's dispatch lock, and a re-read names the alarms the live stream restated while it was in flight as present, so a live `Raise` newer than the query is never cleared. Alarms outside the live subscription are never swept. The same sweep also repairs an alarm that cleared during a stream gap (gateway restart).
|
||||
|
||||
**`provider_status` / `snapshot_status` frames and truncated snapshots (#945).** The gateway's stream opens with a `provider_status` and a `snapshot_status` frame and repeats them on failover/failback and on a change of the truncation verdict. Both are consumed, not counted as `galaxy.alarm_feed.transitions.decoding_failures`: `provider_status` is logged (Warning when degraded, i.e. the subtag fallback) and counted on `galaxy.alarm_feed.provider_status` (tags `mode`, `degraded`); `snapshot_status` is logged and counted on `galaxy.alarm_feed.snapshot_status` (tag `truncated`). A snapshot the gateway flags as possibly incomplete (latest `snapshot_status.truncated`, or, for a gateway that sends no status frame, a per-record `from_truncated_snapshot` on an entry; a re-read is also judged by its entries' flags) is **not complete**: its entries are still raised, but `SnapshotDelivered` / `ActiveSetDelivered` are not (no known-state signal, and no sweep, since absence from a possibly-truncated set proves nothing; counter `galaxy.alarm_feed.snapshot_withheld`). When the gateway later reports `truncated = false` after a withheld read, the feed raises `SnapshotTruncationCleared` and the driver re-reads the active set, whose complete result sweeps and signals. Until then the conditions stay unknown (F5 diagnoses them). A re-read that straddles the clearing frame is not retried (bounded); it waits for the next sentinel or subscription refresh.
|
||||
|
||||
## Testing
|
||||
|
||||
- **Unit tests**: `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Tests/` — fakes the gateway gRPC surface; covers Browse, Runtime, Health, and Config in isolation.
|
||||
|
||||
Reference in New Issue
Block a user