Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement polling reports in synapse #259

Merged
merged 38 commits into from
Jul 4, 2022
Merged

implement polling reports in synapse #259

merged 38 commits into from
Jul 4, 2022

Conversation

jesopo
Copy link
Contributor

@jesopo jesopo commented Mar 23, 2022

we already have a method for getting reports in to mjolnir by asking an nginx sitting in front of Synapse to redirect the report endpoint to mjolnir, but this seemed fiddly, specific to your reverse proxy, and on matrix.org we want reports to go in to both mjolnir and synapse, so for the time being we landed on this solution.

this polls synapse once a minute to grab any new reports and feeds them in to the same code flow that the reverse proxy intercepting method uses

@jesopo
Copy link
Contributor Author

jesopo commented Mar 23, 2022

i think if we kept the polling delay at once-a-minute, using setInterval is fine, but if it wants to be much faster, we're better off doing setTimeout

Copy link
Contributor

@Gnuxie Gnuxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far

src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/Mjolnir.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Yoric Yoric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use setInterval. If the homeserver has a downtime, this can cause a thundering herd of requests when it returns.

Copy link

@jimmackenzie jimmackenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the PR description:

we already have a method for getting reports in to mjolnir by asking an nginx sitting in front of Synapse to redirect the report endpoint to mjolnir, but this seemed fiddly, specific to your reverse proxy, and on matrix.org we want reports to go in to both mjolnir and synapse, so for the time being we landed on this solution.

this polls synapse once a minute to grab any new reports and feeds them in to the same code flow that the reverse proxy intercepting method uses

Suggested changes

  • Set out what the change does
    • e.g. This change polls Synapse once per minute to grab new abuse reports from users, and pulls them into Mjolnir. This allows us to send the reports to both the Synapse database and to Mjolnir, which we need for matrix.org
  • Set out the options you considered
    • Using an nginx instance sitting in front of Synapse to reverse proxy the report endpoint to Mjolnir
    • Polling Synapse to bring reports from Synapse to Mjolnir
    • What the third choice was (rewriting how we handle reports iirc)
  • Set out why you chose the option in this PR
    • It's quick, not implementation specific, doesn't require a separate dependency in nginx
  • Set out out the risks and potential problems with this choice
    • We may need to rewrite how we handle reports anyway
    • Polling may be slower than we need
    • Polling may be more expensive than we want
    • Making changes to the polling interval involves x

That pattern gives a future troubleshooter a bunch of context about why we are making this change, and the other options that we have considered and discarded. If we're hooking into other code flows, I'd maybe link those up too (such as the code flow for the existing implementation) — it's easy enough to find them, but in a 4am incident, any thinking we save ourselves is a victory! It also makes it easier if we're onboarding other folks onto the team, or if other teams are looking at this code in the future.

@jesopo jesopo requested a review from Gnuxie March 28, 2022 16:07
Copy link
Contributor

@Gnuxie Gnuxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting closer

package.json Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
@jesopo jesopo force-pushed the jess/report-polling branch 2 times, most recently from b590096 to 8319861 Compare April 1, 2022 13:15
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Gnuxie Gnuxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

unsure of whether we need to give this a dedicated test, i believe it is possible #259 (comment)

Copy link
Contributor

@Yoric Yoric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you be surprised if I request tests? :)

src/Mjolnir.ts Outdated Show resolved Hide resolved
src/Mjolnir.ts Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/config.ts Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
@jesopo jesopo requested a review from Yoric May 9, 2022 13:31
Copy link
Contributor

@Yoric Yoric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're almost there!

Lots of trivial nitpicks, because I'm me, and a couple of actual remarks hidden in the middle.

src/Mjolnir.ts Outdated Show resolved Hide resolved
src/Mjolnir.ts Outdated Show resolved Hide resolved
src/Mjolnir.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
src/report/ReportPoll.ts Outdated Show resolved Hide resolved
test/integration/reportPollingTest.ts Outdated Show resolved Hide resolved
test/integration/reportPollingTest.ts Outdated Show resolved Hide resolved
test/integration/reportPollingTest.ts Outdated Show resolved Hide resolved
@jesopo jesopo requested a review from Yoric June 28, 2022 14:44
Copy link
Contributor

@Yoric Yoric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!
A few nits here and there.

src/Mjolnir.ts Outdated Show resolved Hide resolved
src/Mjolnir.ts Show resolved Hide resolved
src/report/ReportPoller.ts Outdated Show resolved Hide resolved
src/report/ReportPoller.ts Outdated Show resolved Hide resolved
src/report/ReportPoller.ts Outdated Show resolved Hide resolved
src/report/ReportPoller.ts Show resolved Hide resolved
test/integration/reportPollingTest.ts Show resolved Hide resolved
@jesopo jesopo merged commit ed68e02 into main Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants