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

Enforce file quota #5228

Closed
30 of 38 tasks
devincowan opened this issue Oct 3, 2023 · 4 comments · Fixed by #5229
Closed
30 of 38 tasks

Enforce file quota #5228

devincowan opened this issue Oct 3, 2023 · 4 comments · Fixed by #5229
Assignees
Labels
3rd Party File Exchange Pulling files from or putting files in a separate system enhancement File System

Comments

@devincowan
Copy link
Contributor

devincowan commented Oct 3, 2023

Describe the feature you'd like and what it will do
File quota system was implemented circa #1566.
However, the quota has not been enforced -- warning notifications are provided but to date users have been permitted to exceed their quota allotments.

Doc used to date: https://docs.google.com/document/d/1OxrX4qPkeYsU0WPu7BMODakCcvSumidallXZjFpnkgo/edit?usp=sharing

We need to turn quota enforcement on.
This will include:

Policy Decisions

  • Decide policy on incentives and thresholds
  • Different quota thresholds for .edu and .gov emails?
  • Published resources will not count toward quota
  • How do we handle existing users who are over quota? Example: user currently has 500GB of storage. When we flip the switch and turn on enforcement, should this user be allowed to retain all of these files? We decided to notify current users who are over quota
  • Bag “shadow” – if someone has a large resource that they generate a bag for, we don’t count toward quota, but once in the cloud we cuahsi would pay for double the storage. If no downloads within a year, should we "offboard" the resource (remove the bag).

HS Development Tasks

  • Form within HS UI Profile to request more quota (including how much, institution, justification).
  • Simplified admin approval process in Mezanine.
  • Add admin approval process via email
  • Add ability to not count published resources against quota
  • Add progress bar in the profile page would be very useful to represent this information. It can indicate the current amount of quota used as a percentage of total quota allocated. Extra credit if it is color coded.
  • Break down quota by user/data zone
  • Users are required to ask for more quota when a new file is uploaded and the quota has been exceeded by the previous upload -- If the upload was rejected then it would be direct for a user to ask for more
  • What happens if someone goes over quota (starts grace period) but then reduces their storage? Does the grace period reset? (Looks like the answer is YES)
  • Modify the "daily" script. Emails to admin/help should be monthly. User gets notification when login (every time). Admins we will keep with a once-per-month notification. User also gets notified every time that they go over the "soft" limit
  • Ensure that we are enforcing quota at the proper times
  • Published resource % should be configurable in the admin dashboard for QuotaMessages
  • "Revoke" quota request -> "cancel"
  • "File upload disabled due to quota enforcement" -> "Due to your storage being over Quota"
  • Check that remaining grace period is reset when UQ below soft limit
  • "Current users over quota are contacted and quota is adjusted" -- check email process / management script
  • If no downloads within a year, should we "offboard" a resource's zipped bagit archive #5310 created a separate issue for this
  • Enforcement for uploads conducted via API and HS UI (ideally before the upload starts to prevent user waiting only to find that they have exceeded quota after the upload completes)
  • Add the ability to move instead of copy from UserZone to DataZone #5318 created a separate issue for this
  • Just have default messaging for users that don't have an iRods account
  • Uploads in process are completed even if the results in going over the quota limit (unless we know the upload size before upload starts)
  • FB: more obvious red notification above the FB
  • make JS notifications persistent so that it doesn't dismiss before there's a chance to read
  • Check enforcement when copying files from UZ to DZ: yes, enforced in file_add_pre_process
  • Write additional tests especially for handling of QuotaException
  • Currently, we rely on a celery task to decrement the remaining_grace_period. This is a bad idea. What if celery task stalls? What if the task gets run manually instead of triggered periodically? Instead, we could store the date/time that the grace period will end

Devops Tasks

  • Ensure protections exist to prevent issues (undesired notifications etc) on non-prod deploys
  • Add the rules that exist on the beta dataZone to the beta userZone
  • After additional testing, create a dot release checklist for deployment of the new engine, msi, and rule on production

Irods Development Tasks

Messaging and Documentation

  • User messaging, update help.hydroshare.org
  • Quota messages are stored in the db -- they must be updated
  • Notify current users who are over quota
@devincowan devincowan added File System enhancement 3rd Party File Exchange Pulling files from or putting files in a separate system labels Oct 3, 2023
@devincowan devincowan self-assigned this Oct 3, 2023
@devincowan devincowan added this to Backlog in HydroShare Issue Management Board via automation Oct 3, 2023
@devincowan devincowan moved this from Backlog to In Progress in HydroShare Issue Management Board Oct 3, 2023
@devincowan
Copy link
Contributor Author

devincowan commented Oct 3, 2023

related to #4447 and #5195

@devincowan
Copy link
Contributor Author

devincowan commented Oct 3, 2023

Some places we need to check enforcement:

file add

https://github.com/hydroshare/hydroshare/blob/2.8.1/hs_core/hydroshare/utils.py#L987
image
The formatting is pretty ugly–we should fix it

Resource create

https://github.com/hydroshare/hydroshare/blob/master/hs_core/hydroshare/utils.py#L832
Currently, if I am over quota and enforce=True, a generic error is shown when I try to create a new resource–even though the create-resource request actually returns the JSON containing quota message:
image

Resource copy

I don’t think that we validate before starting the copy, we just probably throw an exception during the copying process
image
https://github.com/hydroshare/hydroshare/blob/2.8.1/hs_core/tasks.py#L568

Resource version

Doesn’t look like we validate before copying
https://github.com/hydroshare/hydroshare/blob/2.8.1/hs_core/tasks.py#L604
This is a problem because we lock the resource during copy, so the resource would remain locked after the QuotaException
We attempt to unlock it but in this case the ori_res will be unbound:

Traceback (most recent call last):
  File "/hydroshare/hs_core/tasks.py", line 661, in create_new_version_resource_task
    ori_res.locked_time = None
UnboundLocalError: local variable 'ori_res' referenced before assignment

Owner transfer

https://github.com/hydroshare/hydroshare/blob/2.8.1/hs_core/models.py#L2340
This is well handled! Other cases should be modeled after this.
image

Replicate bag or ingest from userzone

https://github.com/hydroshare/hydroshare/blob/2.8.1/hs_core/tasks.py#L695

Add url file to res

https://github.com/hydroshare/hydroshare/blob/master/hs_core/views/resource_folder_hierarchy.py#L553
Looks like this is still possible even after quota exceeded

Unzip (via UI and API)

Tested, looks like this is currently permitted even for user that is over quota.

API file add

Endpoints look like they use the resource_file_add_pre_process which calls validate_user_quota
image

devincowan added a commit that referenced this issue Oct 3, 2023
devincowan added a commit that referenced this issue Jan 6, 2024
devincowan added a commit that referenced this issue Jan 19, 2024
devincowan added a commit that referenced this issue Jan 19, 2024
devincowan added a commit that referenced this issue Jan 19, 2024
devincowan added a commit that referenced this issue Jan 19, 2024
devincowan added a commit that referenced this issue Jan 19, 2024
devincowan added a commit that referenced this issue Apr 29, 2024
devincowan added a commit that referenced this issue Apr 29, 2024
devincowan added a commit that referenced this issue May 9, 2024
devincowan added a commit that referenced this issue May 9, 2024
@devincowan devincowan linked a pull request May 9, 2024 that will close this issue
5 tasks
@devincowan devincowan removed a link to a pull request May 9, 2024
5 tasks
devincowan added a commit that referenced this issue May 10, 2024
devincowan added a commit that referenced this issue May 13, 2024
The migrations `0080_baseresource_quota_holder.py`, `0080_resourcefile_filesize_cache_updated.py`, `0081_alter_baseresource_quota_holder.py`, and `0082_merge_20240509_1646.py` are no longer needed and have been deleted. These migrations were related to the `baseresource` model's `quota_holder` field and the `resourcefile` model's `filesize_cache_updated` field. The changes made in these migrations have been consolidated into a new migration `0080_baseresource_quota_holder_squashed_0082_merge_20240509_1646.py`, which adds both fields to their respective models.
devincowan added a commit that referenced this issue May 14, 2024
@devincowan devincowan moved this from In Review to Merged in HydroShare Issue Management Board May 14, 2024
devincowan added a commit that referenced this issue May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd Party File Exchange Pulling files from or putting files in a separate system enhancement File System
1 participant