fix(alerts): an alert on a count says how many of what, and names them (#6400)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m36s
CI / integration (push) Successful in 1m48s
CI / publish (push) Successful in 1m8s

"swarm services short on swarm is 6." becomes "6 swarm services are
short of their replicas.", with a Which line naming each service and how
many of its tasks run. The swarm figures get labels, and the counting
figures (swarm, mounts, drives, updates) read as sentences in the email,
its subject and the Alerts page. A plugin names what its count counts
through core.alerts.names_behind; the Docker plugin does for the three
swarm figures, from the stored swarm. Webhooks get alert.which too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 13:00:56 -04:00
co-authored by Claude Opus 5.5
parent ae789bc0f1
commit 0b787a0676
17 changed files with 308 additions and 24 deletions
+10
View File
@@ -21,6 +21,16 @@ def test_services_short_of_their_replicas_are_counted():
{"service_name": "d", "desired": 0, "running": 0}, # scaled to 0: wants none
{"service_name": "e", "desired": 1, "running": 2}]} # an update overlapping
assert sh.figures(swarm)["swarm_services_short"] == 2
# An alert on it names them, with how many of each run (#6400).
assert sh.short_services(swarm["services"]) == ["a (0 of 1 running)", "b (2 of 3 running)"]
def test_the_nodes_and_managers_counted_are_named():
nodes = [_node("util01", availability="drain", status="down"), _node("docker02", status="down",
reachability="unreachable"), _node("docker03"), _node("worker1", role="worker", status="disconnected")]
assert sh.down_nodes(nodes) == ["docker02 (down)", "worker1 (disconnected)"]
assert sh.unreachable_managers(nodes) == ["docker02"]
assert set(sh.NAMERS) == set(sh.SWARM_METRICS)
def test_a_drained_node_going_away_is_expected():