Repository navigation
feat: deprecate get_storage_class in core/storage.py - #36910
Conversation
|
Thanks for the pull request, @dwong2708! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
52e93e7 to
bed450a
Compare
3033d45 to
085e01a
Compare
2607ef4 to
6197b2d
Compare
f6a4a32 to
d0a3e95
Compare
feanil
left a comment
There was a problem hiding this comment.
Some comments but generally I think the approach is good, it will be nice to clean it all up in a future release but I think this is good for transitioning.
| if isinstance(storage_path, dict) and legacy_sec_setting_keys: | ||
| for deep_setting_key in legacy_sec_setting_keys: | ||
| # For legacy dict settings like settings.CUSTOM_STORAGE = {"BACKEND": "cms.custom.."} | ||
| storage_path = storage_path.get(deep_setting_key) |
There was a problem hiding this comment.
If the legacy_sec_setting_keys has 2 items in the list, and the first one returns None I think this will throw an exception when you try None.get...
We should add a test case for that and I think it's fine to raise the exception but maybe catch and re-raise it with extra context.
There was a problem hiding this comment.
I tried to add an exception as suggested, but I noticed that when running pytest, the exception is raised immediately. This happens because calls like this one to a CustomizableFileField are executed eagerly during model field initialization.
Because of that, I decided to keep the code as a simple validation that falls back to the default storage when needed. What do you think about this approach?
| config = settings.VERIFY_STUDENT["SOFTWARE_SECURE"] | ||
|
|
||
| # Default to the S3 backend for backward compatibility | ||
| storage_class = config.get("STORAGE_CLASS", "storages.backends.s3boto3.S3Boto3Storage") |
There was a problem hiding this comment.
We're changing behavior here a bit, previously if no storage class was provided it would fallback to S3 specifically. Now it will fallback to the default storage class. I think this is an improvement but because it's also a change in behavior, we should communicate it and make sure it's in the operator/dev notes for Ulmo.
There was a problem hiding this comment.
I was thinking of adding an extra parameter to resolve_storage_backend to allow passing in a fallback_storage_class, and use that as the default instead of FileSystemStorage. What do you think?
There was a problem hiding this comment.
I don't think that's necessary, I think we can just make a note about this. Previously this would fail if you didn't explicitly configure it, now it will fallback to your default storage class which I think is an improvement, we just need to document it in the Ulmo notes.
There was a problem hiding this comment.
I agree. I just updated the dev notes for Ulmo. Thanks Feanil.
eefaf84 to
fe002c0
Compare
feanil
left a comment
There was a problem hiding this comment.
@dwong2708 just a couple of questions but I'm hoping we can land this soon.
| config = settings.VERIFY_STUDENT["SOFTWARE_SECURE"] | ||
|
|
||
| # Default to the S3 backend for backward compatibility | ||
| storage_class = config.get("STORAGE_CLASS", "storages.backends.s3boto3.S3Boto3Storage") |
There was a problem hiding this comment.
I don't think that's necessary, I think we can just make a note about this. Previously this would fail if you didn't explicitly configure it, now it will fallback to your default storage class which I think is an improvement, we just need to document it in the Ulmo notes.
| "CERT_VERIFICATION_PATH": False, | ||
| }, | ||
| "DAYS_GOOD_FOR": 10, | ||
| "STORAGE_CLASS": "storages.backends.s3boto3.S3Boto3Storage" |
There was a problem hiding this comment.
Why did you add this setting to the test? Is this required now or was this just to improve test coverage? If it's required, do we need to document that somewhere so that operators know to change their settings?
There was a problem hiding this comment.
This is now a requirement. Where is the appropriate place to document it?
There was a problem hiding this comment.
We should also add this to the Ulmo page but we'll want to communicate it to people who are close following master so probably also worth posting it to the discussion forums. There is an @early-deployers group you can tag on a post, just post it as a maintainers announcement.
FYI @jristau1984 @timmc-edx as this will be something 2U will need to add to their settings before we merge this change to master as a part of the Django 5.2 upgrade.
Correct me if I'm wrong @dwong2708 but I think before the storage class was defaulting to S3 rather than whatever the default storage class was set to. So now if you want to explicitly use s3 storage for this, you have to set it.
There was a problem hiding this comment.
This is the top-level STORAGE_CLASS setting, right?
There was a problem hiding this comment.
We should also add this to the Ulmo page but we'll want to communicate it to people who are close following master so probably also worth posting it to the discussion forums. There is an
@early-deployersgroup you can tag on a post, just post it as a maintainers announcement.FYI @jristau1984 @timmc-edx as this will be something 2U will need to add to their settings before we merge this change to master as a part of the Django 5.2 upgrade.
Correct me if I'm wrong @dwong2708 but I think before the storage class was defaulting to S3 rather than whatever the default storage class was set to. So now if you want to explicitly use s3 storage for this, you have to set it.
That's correct
There was a problem hiding this comment.
This is the top-level
STORAGE_CLASSsetting, right?
In Django settings, the storage class for VERIFY_STUDENT is defined like this:
VERIFY_STUDENT = {
"SOFTWARE_SECURE": {},
"DAYS_GOOD_FOR": 10,
"STORAGE_CLASS": "storages.backends.s3boto3.S3Boto3Storage"
}
There was a problem hiding this comment.
We should also add this to the Ulmo page but we'll want to communicate it to people who are close following master so probably also worth posting it to the discussion forums. There is an
@early-deployersgroup you can tag on a post, just post it as a maintainers announcement.FYI @jristau1984 @timmc-edx as this will be something 2U will need to add to their settings before we merge this change to master as a part of the Django 5.2 upgrade.
Correct me if I'm wrong @dwong2708 but I think before the storage class was defaulting to S3 rather than whatever the default storage class was set to. So now if you want to explicitly use s3 storage for this, you have to set it.
Done. Here the announcement https://discuss.openedx.org/t/deprecation-notice-verify-student-storage-class-in-favor-of-django-s-storages/16707
1184c17 to
5f40fe6
Compare
feanil
left a comment
There was a problem hiding this comment.
This looks good, I'm planning on Merging it Thursday so that early deployers have enough time to react if they need to to the one breaking change.
|
Sandbox deployment failed 💥 |
5f40fe6 to
7479beb
Compare
|
Sandbox deployment successful 🚀 |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
Fixes: #36739
The main goal is to modify the get_storage_class function referenced here in order to deprecate it.
However, a few special changes have been made, as described below:
Why does the get_storage_class function still exist with a new implementation that uses
import_string?This change is related to the DjangoStorageReportStore class and its parent implementation. Specifically, here, a dynamic logic is used to define the storage backend.
Given the complexity of that logic, I recommend creating a separate ticket to refactor this part of the code.
Lastly, the
resolve_storage_backendfunction was updated to support alegacy_sec_setting_keysparameter. This allows it to handle storage settings defined as nested dictionaries. For example: