Repository navigation
Description
Found while planning the udp-core banning tests in #1348 (EPIC #1347).
Goal
Make the "banned IPs" metric (udp_tracker_server_ips_banned_total in Prometheus, udp_banned_ips_total in the REST stats) report what its name and descriptions say, and keep it correct after the periodic ban reset.
Bug
BanService::get_banned_ips_total() in udp-core returns the number of IPs with at least one invalid connection ID, not the number of IPs whose count exceeds max_connection_id_errors_per_ip (which is what is_banned uses). The udp-server banning handler publishes that value to the gauge after every connection-cookie error, and the REST stats read the same gauge. Separately, the periodic ban reset clears the counters but never updates the gauge, so after a reset it keeps reporting the old total until the next invalid connection ID arrives.
Reproduced on develop at 1c5939c76 against the running tracker (limit 10, strict validation): one invalid connection ID from each of three IPs plus 11 from a fourth IP made the REST JSON stats, the REST Prometheus stats, and the Prometheus metrics all report 4 banned IPs. Only the fourth IP was actually banned (its next request was dropped and udp_tracker_server_requests_banned_total was 1); the other three were still served.
Impact: operators see an inflated and, after a reset, stale "banned IPs" count. Ban enforcement itself is correct.
Decisions
- When connection-ID validation is
disabled, the metric reports IPs over the limit ("would-be banned", not enforced), and the documentation says so. No metric or REST field is renamed. - Remove the unused
BanningStatstrait (an SI-30 leftover from SI-30: Decouple rest-api-core and axum-rest-api-server from concrete UDP server internals #1924 that SI-4: Migrate stats context to contract-first architecture #1942 never consumed) and the write-onlyBanService::last_connection_id_errors_resetfield (never read since Ban socket addresses not sending a valid connection ID #1096).
Acceptance criteria
- AC1: The banned-IPs total counts only IPs whose error count exceeds the limit, in both
strictanddisabledmode. - AC2: After a ban reset, the banned total and the published gauge report the new value.
- AC3: The method, metric,
udp-serverhelper, and REST field descriptions match the behavior, including thedisabled-mode meaning. - AC4: The
BanningStatstrait andBanService::last_connection_id_errors_resetare removed. - AC5: The
udp_ban_servicebenchmark is recorded before and after the change, with no regression onincrease_counteroris_banned. - AC6: The reproduction is repeated after the fix and recorded.
-
linter allexits with code0 - Relevant tests pass
- Manual verification scenarios are executed and documented in issue-local
manual-verification-evidence.md - Acceptance criteria are re-reviewed after implementation and reflect actual behavior
Specification: docs/issues/open/2505-udp-banned-ips-metric/ISSUE.md (added by the spec-only PR), with the reproduction evidence in the same folder.
Activity
docs(issues): [torrust#2505] require constant per-event cost for the …
docs(issues): [torrust#2505] plan the request-path performance evidence
docs(issues): [torrust#2505] keep the banned-count fix and its depend…
docs(issues): [torrust#2505] make the property and disabled-mode test…
docs(issues): [torrust#2505] validate the reproduction probe arguments
docs(issues): [torrust#2505] record the exact reproduction commands
docs(pr-reviews): [torrust#2505] add the PR torrust#2506 review audit
docs(issues): [#2505] add specification for the UDP banned-IPs metric…
Merge #2506: docs(issues): [#2505] add specification for the UDP bann…
docs(issues): [torrust#2517] say where the SI-30 traits work is recorded
docs(issues): [torrust#2521] use stable issue references in related a…
docs(issues): [torrust#2521] add issue specification for torrust#2521
101 remaining items
docs(pr-reviews): [#2505] close the PR #2506 post-merge findings
Merge #2528: chore(issues): archive the closed #2505 spec and close i…
docs(issues): [torrust#2521] record the rebase onto the torrust#2505 …
Merge #2529: refactor: [#2521] remove the unused UDP statistics trait…
Merge #2530: chore(issues): archive closed issue #2517 spec
docs(benchmarking): plan the expected cost of deliberately added work
docs(benchmarking): check for running trackers and busy ports before …
docs(skills): confirm a mutation compiled before reading its test result
docs(benchmarking): process numeric evidence with LC_ALL=C
docs(skills): run the final bug recheck after the last production change
docs(templates): run dependent manual verification steps one at a time
docs(skills): run each signed commit as its own step
Merge #2534: docs(skills): apply the #2505 retrospective process impr…
docs(udp-core): point the banning records at the merged torrust#2505
Merge #2538: test(udp-core): [#1348] add tests to the udp-core package