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

resolve bad migration operation causing drop of permissions (fixes #403) #407

Merged
merged 2 commits into from
Mar 26, 2021

Conversation

fmigneault
Copy link
Collaborator

@fmigneault fmigneault commented Mar 26, 2021

resolve bad migration operation causing drop of permissions (fixes #403)

@fmigneault fmigneault added the db Issues related to database connection, migration or data models label Mar 26, 2021
@fmigneault fmigneault requested a review from tlvu March 26, 2021 16:17
@fmigneault fmigneault self-assigned this Mar 26, 2021
@github-actions github-actions bot added ci Something related to code tests, deployment and packaging doc Documentation improvements or building problem labels Mar 26, 2021
tlvu
tlvu previously approved these changes Mar 26, 2021
Copy link
Contributor

@tlvu tlvu left a comment

Choose a reason for hiding this comment

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

Approve the spirit of it as I have no knowledge of DB migration.

Curious, how do you know this will fix the issue since I do not see any new test case reproducing the issue to confirm the fix works?

I assume once this PR is merged, you'll create a new Magpie docker and test a migration in a real PAVICS stack using our birdhouse-deploy recipe?

@@ -43,7 +43,7 @@ def upgrade():
grp_res_perms = GroupResourcePermissionService.base_query(db_session=session)
usr_res_perms = UserResourcePermissionService.base_query(db_session=session)

for perm_list in [grp_res_perms, usr_res_perms]:
for item_id_key, perm_list in [("group_id", grp_res_perms), ("user_id", usr_res_perms)]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I have no idea about DB migration but shouldn't the fix be in a new migration step? Fixing in an existing migration step means a server that already execute this step won't attempt it again and miss out on the fix?

Discard what I said if it makes no sense since I know nothing about DB migration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It has to be applied there so that a server that did not run the migration will do it properly after rollback.
If added as new step, permissions will still be dropped at that step and later 'new' step will have no effect as there is nothing left to work with.
Migration steps have their own version dissociated from magpie versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

It has to be applied there so that a server that did not run the migration will do it properly after rollback.

Oh wait so there is a way to rollback a DB migration? I didn't have to rm -rf /data/magpie_persist when reverting from 3.5.1 to 1.7.3?

@fmigneault
Copy link
Collaborator Author

fmigneault commented Mar 26, 2021

Curious, how do you know this will fix the issue since I do not see any new test case reproducing the issue to confirm the fix works?

I assume once this PR is merged, you'll create a new Magpie docker and test a migration in a real PAVICS stack using our birdhouse-deploy recipe?

@tlvu
I used birdhouse-deploy version 1.11.24 and applied all permissions seen in #401, then ran the migration operations via debug script to step through lines. I noticed that the permission resolution was incorrectly matching bad permissions together based on that the missing compare this PR adds.
After patch, the permissions seem to remain as expected. (still need to test on your side though, as I don't have the full database)

I will tag another version after the few recent bugfixes are merged.

@fmigneault fmigneault merged commit c1b8d09 into master Mar 26, 2021
@fmigneault fmigneault deleted the resolve-migration-perm-drop branch March 26, 2021 21:54
@tlvu
Copy link
Contributor

tlvu commented Mar 27, 2021

I used birdhouse-deploy version 1.11.24 and applied all permissions seen in #401,

You meant #403? Not #401 right?

@fmigneault
Copy link
Collaborator Author

fmigneault commented Mar 29, 2021

You meant #403? Not #401 right?

@tlvu

Yes. My bad.
I tagged a new version 3.8.0 with all fixes.
You can let me know if you see any more errors.

@tlvu
Copy link
Contributor

tlvu commented Mar 30, 2021

I tagged a new version 3.8.0 with all fixes.
You can let me know if you see any more errors.

@fmigneault

Woo a jump from 3.5.1 to 3.8.0? So during last Magpie upgrade, 3.7.0 was available but we didn't want to use it?

Before I spend, and potentially waste time on this 3.8.0 again, what tests did you perform on this 3.8.0? Is it integrated here https://github.com/bird-house/birdhouse-deploy/compare/restore-previous-broken-magpie-upgrade-so-we-can-work-on-a-fix, how has it been tested?

@dbyrns
Copy link
Contributor

dbyrns commented Apr 1, 2021

@tlvu, Francis tests the migration to 3.8.0 using this procedure : #407 (comment).
So this migration is tested and safe. However, no migration should be done to an earlier version as, like we discussed with @huard, we don't want to support old versions and the fix is in 3.8.0. The only thing we cannot do is testing with your own server data, so hopefully you will not waste your time this time. Also remember that Magpie has an exhaustive list of tests, but edge cases with production data are hard to predict and it's not because of ill will that errors happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Something related to code tests, deployment and packaging db Issues related to database connection, migration or data models doc Documentation improvements or building problem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Many existing service permissions on group anonymous lost after upgrading from 1.7.3 to 3.5.1
3 participants