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

Remove django fernet #447

Merged
merged 3 commits into from
Aug 10, 2023
Merged

Remove django fernet #447

merged 3 commits into from
Aug 10, 2023

Conversation

awais786
Copy link
Contributor

@awais786 awais786 commented Aug 10, 2023

Trying to remove djfernet from this repo. Its un-used import exists in migration.

Model is already removed in following prs.
#229
#232

These two PRs removed actual code/models but some thing still exists in migration.

Will remove djfernet in next release.

@@ -170,8 +169,6 @@ class Migration(migrations.Migration):
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
('org', models.CharField(help_text='This value must match the value of organization in studio/edx-platform.', max_length=50, verbose_name='Organization')),
('provider', models.CharField(choices=[('Custom', 'Custom'), ('3PlayMedia', '3PlayMedia'), ('Cielo24', 'Cielo24')], max_length=50, verbose_name='Transcript provider')),
('api_key', fernet_fields.fields.EncryptedTextField(max_length=255, verbose_name='API key')),
Copy link
Contributor Author

@awais786 awais786 Aug 10, 2023

Choose a reason for hiding this comment

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

This model already deleted in last migration. So removing these fields will not effect stage or prod since these are already executed there.
https://github.com/openedx/edx-val/blob/master/edxval/migrations/0003_delete_transcriptcredentials.py

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs more thought. It's not just our stage/prod, but every Open edX deployment across the globe that needs to be accounted for.

The simple way to handle this is squashing migrations: https://openedx.atlassian.net/wiki/spaces/AC/pages/23003228/Everything+About+Database+Migrations#EverythingAboutDatabaseMigrations-SquashingMigrations. However, the old outdated migrations would normally not be deleted until after the next Open edX named release.

Is that too late? If so, this needs some additional thinking. For example, maybe the migration that removes the fields would need to be conditional on whether they actually exist? But editing old migrations is always scary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These models/migrations were delete around May 27, 2020.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • The safe way to do this is to squash migrations. The problem is that it wouldn't matter how old the migrations are, you'd need to wait until everyone has run the squashed migration before deleting the old, which means waiting through a named release cycle.
  • The riskier way of doing this is to edit the old migrations.
    • If you choose to go this path, I'd make this all more clear by removing the entire CreateModel for TranscriptCredentials in this migration, and the entire delete model for 0003. You could explain everything in the PR comment and description.
    • The problem would be if 0001 and 0003 were added as parts of different named releases. In that case, someone could have a DB that has run 0001 and not 0003, which is what squashing takes into account.
    • An alternative is to remove the CreateModel from 0001, but make 0003 remove the model only if needed. I'm not sure exactly how that would be coded, but that should take care of this weird case.
    • Or, if 0001 and 0003 were both added in the same single named release, then it may be safe to edit both at the same time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh. I realize that in requesting that the whole model be deleted to add clarity, I inadvertently made it all more complex. I think your solution is probably fine as-is, but I just want a little more time to think about it. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry it took me some time to grasp this more completely. I think this covers all the cases I was concerned with as-is. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @robrap for detailed review. As always, it contains incredibly valuable guidelines.

@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (9dd7896) 94.40% compared to head (811e1b3) 94.40%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #447   +/-   ##
=======================================
  Coverage   94.40%   94.40%           
=======================================
  Files          28       28           
  Lines        3001     3001           
  Branches      168      168           
=======================================
  Hits         2833     2833           
  Misses        150      150           
  Partials       18       18           
Flag Coverage Δ
unittests 94.40% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
edxval/__init__.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -170,8 +169,6 @@ class Migration(migrations.Migration):
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
('org', models.CharField(help_text='This value must match the value of organization in studio/edx-platform.', max_length=50, verbose_name='Organization')),
('provider', models.CharField(choices=[('Custom', 'Custom'), ('3PlayMedia', '3PlayMedia'), ('Cielo24', 'Cielo24')], max_length=50, verbose_name='Transcript provider')),
('api_key', fernet_fields.fields.EncryptedTextField(max_length=255, verbose_name='API key')),
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry it took me some time to grasp this more completely. I think this covers all the cases I was concerned with as-is. Thank you.

@awais786 awais786 merged commit 3632977 into master Aug 10, 2023
8 checks passed
@awais786 awais786 deleted the remove-django-fernet branch August 10, 2023 18:03
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.

3 participants