-
Notifications
You must be signed in to change notification settings - Fork 28
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
Move state of reports to the filesystem #91
Conversation
* Instead of having the report IDs in memory we have two files in the temporary raw_reports directory. One named like the report ID is the actual reports. Another is instead a file containing the metadata for the report. This implements one of the proposed solutions outlined in #86
…cking * We consider a report to be stale if current_time - modification time of report metadata is > than stale_time
Epic! Will review and test this! |
from oonib.deck.api import deckAPI | ||
from oonib.report.api import reportAPI | ||
from oonib.input.api import inputAPI | ||
from oonib.policy.api import policyAPI | ||
from oonib.bouncer.api import bouncerAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For symmetry with moving APIs in class scope you would probably want to move also this statement
The test where I shut down and then restarted oonib while ooniprobe was running a deck was quite interesting. I lost some entries, of course, but after oonib came up again, everything continued to work and subsequent entries were appended to the report file. As regards testing using the old YAML format, I checked out
What I obtain is this error and of course no report is created:
@hellais, any hint? |
I believe the issue lies in the fact that ooniprobe 1.3.2 doesn't support non httpo collectors (i.e. https or http). I would advise you run it by specifying the collector address in httpo format. |
* Implement a unittest for verifying that the stale report cleaning function works.
Yes, this strategy is working, thanks! |
I've done more testing! Going to merge! |
This implements one of the solutions outlined in #86 to support saving the state of a ooni-backend instance when it is shutdown.
Basically we have two files for an opened report with ID
$REPORT_ID
they both reside in the$REPORTS_DIR
.$REPORTS_DIR/$REPORT_ID
is the actual partial report, that get's updated every time we need to create a new entry.$REPORTS_DIR/$REPORT_ID-metadata.json
contains the metadata associated with this report (the metadata sent onopen()
).Every time we get a new update request we append to file 1. and touch file 2.
At regular intervals we look inside of the
$REPORTS_DIR
for all files ending with-metadata.json
and look at theirmtime
withstat
. If they have not been modified in a time frame greater than the stale_time we consider them stale and close them.