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

Add CinderPolicy model and sync_cinder_policies management command #21773

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

KevinMind
Copy link
Contributor

@KevinMind KevinMind commented Jan 31, 2024

Fixes: mozilla/addons#9434

Description

  1. update CinderPolicy to make uuid unique and add parent field for nesting. On a separate commit to be cherry pickable if we want to push early/separately

  2. add a task/command to sync cinder policies to our database.

Context

Since we want to be able to trigger this either via manage.py or via cron a task seemed appropriate. There are many opinions about when to use tasks so happy to hear feedback.

Testing

  1. you need a CINDER_API_TOKEN (talk to @eviljeff). set it in settings_local
  2. make shell
  3. ./manage.py sync_cinder_policies
  4. Check your local database and expect CinderPolicy records to exists. Policies are related via nested_policies as child policies.

@KevinMind KevinMind requested review from a team and diox and removed request for a team January 31, 2024 09:39
src/olympia/abuse/tasks.py Outdated Show resolved Hide resolved
src/olympia/abuse/tasks.py Outdated Show resolved Hide resolved
@diox
Copy link
Member

diox commented Jan 31, 2024

Oh, while you're at it, to help debugging, consider adding a simple __str__ to CinderPolicy like this one:

    def __str__(self):
        return self.name

Copy link
Member

@eviljeff eviljeff left a comment

Choose a reason for hiding this comment

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

I don't have anything to add beyond Mat's review. My merging of another PR has caused a merge conflict in this patch though.

@KevinMind KevinMind force-pushed the ADDSRV-669 branch 4 times, most recently from 122cb24 to 41632bd Compare February 1, 2024 08:54
@KevinMind
Copy link
Contributor Author

There is a conflicting migration as well. Recreating mine.

@KevinMind KevinMind merged commit fb8a38e into master Feb 1, 2024
10 checks passed
@KevinMind KevinMind deleted the ADDSRV-669 branch February 1, 2024 12:26
@KevinMind
Copy link
Contributor Author

How did this not trigger a CI error? @diox any ideas? I suppose our linter isn't actually tracking dependencies? Should that be the case? Feels wrong.

@diox
Copy link
Member

diox commented Feb 1, 2024

You didn't have a test covering the management command, so that didn't break CI

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.

Add management command to sync policies from cinder to AMO
3 participants