fix(alerts): a silence ends when Steward hears of it, once (#5720)
An agent's flushed backlog brings samples hours old. The resume was stamped at the first old sample's time, inside the silence it ended, and silence was still judged by the backlog's sample times, so the series was marked silent again between posts and resumed a second time. A resumed series now counts as heard at ingest time, its events from that batch are stamped no earlier, and the rest of the backlog reads as late samples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -151,3 +151,19 @@ def test_muted_by_names_the_window_that_covers_the_rule():
|
||||
assert _muted_by(windows[:1], rule) is None
|
||||
assert _muted_by([NS(name="all", scope_source=None, scope_resource=None)], rule) == (
|
||||
"notification muted: maintenance window all")
|
||||
|
||||
|
||||
def test_a_flushed_backlog_counts_as_heard_when_it_arrives():
|
||||
"""#5720: an agent's backlog, flushed a couple of samples a post, is hours
|
||||
old. Judged by its newest sample, the series read silent again between
|
||||
posts and resumed twice. It counts as heard when Steward heard it, and the
|
||||
rest of the backlog reads as late."""
|
||||
st = _state(last_sample_at=NOW - timedelta(hours=3), sample_interval_s=60,
|
||||
no_data_since=NOW - timedelta(hours=2, minutes=55))
|
||||
note = _track_samples(st, _samples((2 * 3600 + 60, 5.0), (2 * 3600, 5.0)), NOW)
|
||||
assert note == "data resumed after 2h 55m silent"
|
||||
assert st.last_sample_at == NOW
|
||||
assert silent_since(st.last_sample_at, st.sample_interval_s, NOW, NOW) is None
|
||||
# The next post of the same backlog is late: no gap, no second resume.
|
||||
assert _track_samples(st, _samples((2 * 3600 - 60, 5.0)), NOW) is None
|
||||
assert st.last_sample_at == NOW
|
||||
|
||||
Reference in New Issue
Block a user