Repository navigation
fix(metrics): drop connection on write timeout - #127
bappisinsane wants to merge 1 commit into
Conversation
jamesconwaydev
left a comment
There was a problem hiding this comment.
Thanks for taking this one too. It has the same three gaps as #126, so my review there applies here as well:
- A test that fails on
mainand passes with your change. #124 describes it: monkeypatchWRITE_TIMEOUTdown, serve a registry whoserender()returns tens of megabytes, connect with a smallSO_RCVBUFand don't read, then check the connection gets reset or closed. - Sign-off for the
dcocheck:git commit --amend -s --no-edit, then force-push. - A smaller change.
TimeoutErroris already anOSError, so theexceptline can stay as it was.writer.transportalways exists andabort()doesn't raise, so the body comes down towriter.transport.abort(), without thegetattr, thesuppress, thecontextlibimport or thepass.
For the CHANGELOG, say what a reader would notice, something like: "The metrics endpoint closes a connection whose client stops reading, instead of keeping it and its response open after the write timeout (#124)."
I've approved the CI run for this commit, and I'll approve the next one when you push.
|
Addressed all three points:
On the test: I haven't yet added the write-timeout regression test; I'll follow up with it. |
|
Thanks, @bappisinsane. The code change is exactly what I was after, and so is the CHANGELOG line. What's holding it up now is the branch, plus the test you already mentioned. The branch conflicts with The first commit still has no sign-off. The git reset --soft HEAD~2
git commit -s
git fetch https://github.com/jamesconwaydev/sentry-v2 main
git rebase FETCH_HEAD # fix CHANGELOG.md, git add it, git rebase --continue
git push --force-with-leaseThe test is the part I can't merge without. #124 describes what to check: a client that stops reading gets its connection closed after the write timeout. It should fail on |
|
Thanks for the detailed guidance. I'll squash both commits with sign-off, rebase onto main, fix the CHANGELOG heading under [Unreleased], and add the write-timeout regression test per #124. Will push with --force-with-lease and ping once CI is green. |
d7617c0 to
3531729
Compare
|
Nice work, @bappisinsane. The squash and rebase came out clean: So the test is all that's left, and it doesn't have to be big. Start from Push it to this branch and I'll approve the next run. |
…#143) F2 in `docs/security-review.md`. The metrics endpoint had no connection limit, so any local user could hold connections open (5 s each) until the daemon hit its 1024 fd limit, taking the control socket and sinks down with it. The server now closes any connection past 16 open ones. The new test opens two idle connections against a cap of 2 and checks the third is closed at once (on `main` it waits for the header timeout and the test times out), then that a scrape works once they're gone. Off by default, so only hosts with `metrics.enabled = true` were exposed. #127 still covers aborting a connection that stops reading. Signed-off-by: James Conway <148910373+jamesconwaydev@users.noreply.github.com>
Signed-off-by: bappisinsane <108801304+bappisinsane@users.noreply.github.com>
3531729 to
d9b69d5
Compare
|
Same here, @bappisinsane: the fix is right and CI is green on
Same offer stands: if you'd rather I finish it, say so and I'll add the test on top, credit stays yours. |
Fixes #124.
When a write times out, the metrics endpoint now aborts the transport so the buffered reply and the socket are dropped at once instead of waiting for the buffer to flush.
_handleabortswriter.transporton connection/timeout errors.