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

Convert ReusedGUID to AddonGUID, containing fks for all Addons #14406

Merged

Conversation

eviljeff
Copy link
Member

@eviljeff eviljeff requested review from a team and bobsilverberg and removed request for a team May 27, 2020 17:28
addonguids = [
AddonGUID(
addon_id=addon['id'], guid=addon['guid']) for addon in addons]
AddonGUID.objects.bulk_create(addonguids, batch_size)
Copy link
Member Author

Choose a reason for hiding this comment

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

@diox for second opinion on this migration

Copy link
Member

Choose a reason for hiding this comment

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

This might be a little too much for a migration... I guess we can test that on dev/stage and see if it takes too long...

In prod, we'll likely want the site in read only to ensure that no new add-ons are created before the new code is up - Otherwise there is a window between the guids being fetched and new code being deployed where add-ons would not have a corresponding AddonGUID.

Copy link
Contributor

@bobsilverberg bobsilverberg left a comment

Choose a reason for hiding this comment

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

This looks good to me, nice work @eviljeff. I added a couple of questions.

r+wc

ReusedGUID.objects.create(addon=old_two, guid='reuse@')
ReusedGUID.objects.create(addon=old_other, guid='other@')
ReusedGUID.objects.create(addon=old_noguid, guid='')
old_one = addon_factory(status=amo.STATUS_DELETED, guid=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it necessary to set guid to None now, when it wasn't before? Is this just making the test more explicit?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's to match the states the addon instances would be in reality. If they're supposed to be deleted and re-uploaded then the guid would have been reset on the old instance after the new upload.

(If we don't set the guid to None then we'd need to find and update the AddonGUID instance for them to point to guid='reuse@' instead - it'd be AddonGUID.objects.get(addon=old_one).update(guid='reuse@'))

Copy link
Member Author

Choose a reason for hiding this comment

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

... and the guid hasn't been set to None since 2016, when someone changed it in #1471.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now it's back to not setting guid to None.

ReusedGUID.objects.filter(guid=addon.guid).values_list(
'addon_id', flat=True) if addon.guid else [])
AddonGUID.objects.filter(guid=addon.guid)
.exclude(addon=addon)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this exclude now because we don't want the id of the current addon included in this list? Is there any test coverage for this change? I.e., should there be a test where the id for the current addon is in AddonGUID? Maybe that's already covered in the changes to the tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need this exclude now because we don't want the id of the current addon included in this list?

Yes. The current addon wouldn't have been in ReusedGUID before, but is in AddonGUID now.

Is there any test coverage for this change?

the existing test lines below would fail if we don't exclude the current add-on

expected = [
            (f'{old_one.id}', reverse('reviewers.review', args=[old_one.id])),
            (f'{old_two.id}', reverse('reviewers.review', args=[old_two.id])),
        ]

@eviljeff eviljeff force-pushed the 14391-track-all-guid-usage-per-addon branch from 6736be3 to aa63a0a Compare May 29, 2020 09:19
@eviljeff
Copy link
Member Author

rebased to fix the conflicts and to adjust things a little after #14423

@eviljeff
Copy link
Member Author

going to merge. If -dev fails to deploy we can reconsider the migration - though if we don't have it in the migration we'll need to disable bloomfilter generation until it's been executed in some other way.

@eviljeff eviljeff merged commit 5954aaf into mozilla:master May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants