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

Support uploading stash/filter from multiple block types #22884

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KevinMind
Copy link
Contributor

@KevinMind KevinMind commented Nov 22, 2024

Relates to: mozilla/addons#15014

Description

Adds support for uploading filters and stashes simultaneously as well as supporting soft/hard filters.

Context

Supporting #22828

Testing

Setup

  • Setup a local remote server here
  • Set the base replace threshold to a low number (so you can trigger re-uploading of filters without creating a bunch of blocks)
  • enable enable-soft-blocking and blocklist_mlbf_submit waffle switch

src/olympia/constants/blocklist.py

BASE_REPLACE_THRESHOLD = 2

See the test scenarios

from olympia.blocklist.models import BlockType
from olympia.amo.tests import addon_factory, block_factory, version_factory

def _blocked_addon(block_type=BlockType.BLOCKED, **kwargs):
    addon = addon_factory(**kwargs)
    block = block_factory(
        guid=addon.guid, updated_by=user, block_type=block_type
    )
    return addon, block

user = UserProfile.objects.first()

Now you can call the _blocked_addon method to create an addon with block/version of the specified type.

Ex:

_blocked_addon(block_type=BlockType.BLOCKED)
_blocked_addon(block_type=BlockType.BLOCKED)
_blocked_addon(block_type=BlockType.SOFT_BLOCKED)

This PR will not change any of the existing behavior so you expect to see a new stash record if >0Replace threshold changes, also if new filter expect previous stashes to be deleted.

Important @willdurand you need to remove the soft block config key from admin or the deletion will depend on arbitrary soft block times which are probably wrong

Force recreate

First force recreate the filter

./manage.py cron upload_mlbf_to_remote_settings force_base=True

Expect only an attachment record, regardless of what was there before.

Create a stash

Create one new block

_blocked_addon(block_type=BlockType.BLOCKED)
./manage.py cron upload_mlbf_to_remote_settings

Expect a stash record uploaded

Repeat, expect another stash record

Repeat, now expect a new filter and all stashes deleted.

You can create as many soft blocks at any point in this flow and it should have zero impact.

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@KevinMind KevinMind changed the base branch from soft-block-bloom-filter-filter to master November 22, 2024 14:34
@KevinMind KevinMind marked this pull request as ready for review November 22, 2024 14:44
@KevinMind
Copy link
Contributor Author

Screen.Recording.2024-11-22.at.17.01.37.mov

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.

1 participant