Soft-block-bloom-filter-filter #22828
Open
+505
−190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: mozilla/addons#15014
Rleates to: mozilla/addons#15155
Description
Adds logic to generate and write bloom filters for both soft and hard blocked addons. Additionally this PR introduces logic to determine whether we should update one or both bloom filters and or a stash as multiple possible outcomes are possible now. Finally, we handle cleaning up files on a more granular level from both the local storage and remote settings.
Context
Now when we run the
upload_mlbf_to_remote_settings
cron job we will check for both hard and soft blocked items. It is possible to:This adds a bit of complexity we need to address.
Additionally, instead of deleting all records from remote settings, we need to check for the current set of block filters and only delete records older than the older of the two.
Finally, since it is also possible to run the cron when no updates have occurred, we can safely delete mlbf cache files when that happens as there is no benefit from diffing an empty array.
Testing
This is gonna suck to test. First some preparation work.
Setup
mlbf-soft-blocks-enabled
waffle switchsrc/olympia/constants/blocklist.py
upload_mlbf_to_remote_settings
Execute this command to create a new filter/stash iteration
Test Scenarios (admin)
If you've set the base_replace_threshold to 1 then testing this from the admin is the way to go. You can test all the different combinations of state changes to trigger nothing or stash and or filter.
Test Scenarios (django)
You can test the above scenarios from the django shell as well. In a
make djshell
add this codeNow you can call the
_blocked_addon
method to create an addon with block/version of the specified type.Ex:
If you run the cron job now, you'd expect a blocked filter and a stash with the soft blocked version added.
Verify empty stashes are not created
Using the shell approach from above, verify that if the only change is an unsigned version is blocked, that no stash is produced.
Expect: running the cron job produces no stash and is interpreted as a noop event.
Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.