Repository navigation
Refactor UDP error event logic before adding new metrics - #1552
josecelano merged 11 commits into
Conversation
…t sendable The error will be included in the UdpError event ans sent via tokio channel.
Not exposing the original complex error type becuase: - It's too complex. - It forces all errors to be "Sent", "PartialEq". - It would expose a lot of internals.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1552 +/- ##
=========================================
Coverage 83.35% 83.35%
=========================================
Files 275 282 +7
Lines 19601 19728 +127
Branches 19601 19728 +127
=========================================
+ Hits 16339 16445 +106
- Misses 2962 2981 +19
- Partials 300 302 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
ACK a8f3a97 |
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of #1552 as it stands at a94c3ced8 on the default branch.
What still runs: the parse-error wrapper SendableRequestParseError and the renamed Error variants (packages/udp-server/src/error.rs); the ErrorKind payload of Event::UdpError (packages/udp-server/src/event.rs:113-155); handle_error publishing one error event for every error it handles, including errors without a transaction id (packages/udp-server/src/handlers/error.rs:24-61); the transaction id taken from the parse error (packages/udp-server/src/handlers/mod.rs:132-156); and the split of the statistics event handler into one module per event. The ban counting that this change moved into the event listener now runs in a listener of its own, which counts ErrorKind::ConnectionCookie from announce and scrape (packages/udp-server/src/banning/event/handler.rs:21-39) and starts whatever the statistics setting. Two defects of the merged form are already fixed: with tracker_usage_statistics = false no UDP server event was published and no ban was counted (fixed by d81e59e), and the authentication-required event text carried a source path (fixed by 9d1f144).
[Nit] packages/udp-server/src/handlers/mod.rs:135: match e.clone() copies the whole error, including its message String, each time a request fails to parse, only to read a Copy field, and the _ => None arm cannot be reached, because map_err(Error::from) at :96 only yields Error::InvalidRequest. Smallest fix: match &e { Error::InvalidRequest { request_parse_error } => request_parse_error.opt_transaction_id, _ => None }.
[Nit] packages/udp-server/src/error.rs:68: the name SendableRequestParseError reads as the protocol's RequestParseError::Sendable (an error a response can be sent for), but the wrapper also holds Unsendable errors, so the event text of an unsendable parse error, ErrorKind::RequestParse built by the Display at error.rs:74-82 and used at event.rs:127, starts with SendableRequestParseError. The protocol error is already Send, which the description gives as the reason for the wrapper; what it lacks is Clone, because it holds an io::Error, and the event channel needs Clone. Smallest fix: rename it, for example to RequestParseFailure.
Checked and found sound: the conversion of both parse-error variants, which keeps the connection and transaction ids only when the parser returned them; the transaction id handed to handle_error for parse errors and for handler errors; ErrorKind::from covering every current Error variant, with the unknown nested arms falling back to InternalServer; one UdpError event per handled error, counted once in the general error metric and again only for announce cookie errors in the client-software metric; and ban counting from announce and scrape cookie errors, including the ban listener's handling of a lagged receiver and its start independent of the statistics setting. Because ban counting now runs through the event channel after the request is handled, the per-IP limit can be passed by the requests already in flight before the listener records them; that follows from the event-based approach and is not a defect.
I will add a new metric to count which client's software is used when a UDP error is produced (only for connection ID errors, for now).
This PR make some changes before adding the new metric.
Subtasks
Event::UdpErrorevent.