Skip to content

Quota#1254

Merged
ihsaan-ullah merged 11 commits into
developfrom
user-quota
Dec 21, 2023
Merged

Quota#1254
ihsaan-ullah merged 11 commits into
developfrom
user-quota

Conversation

@ihsaan-ullah

@ihsaan-ullah ihsaan-ullah commented Dec 14, 2023

Copy link
Copy Markdown
Collaborator

Linked to #1251

Description

This PR adds the storage quota per user feature.

It includes the following:

  • a new 'quota' field in the User model so each user has its own quota. It can, therefore, changed per a user basis
  • a global default quota variable defined in the settings of the app
  • the users' used space and quota is displayed on the resource page
  • checks has been added on every data upload (submissions, programs and bundles)
    • the front send the the file size among other metadata to the back
    • the back checks if it is ok to upload the file based on the remaining user quota
    • if not ok an error is sent back to the frontend and is displayed to the user
  • using the django admin interface you can update the quota per user

Issues this PR resolves

Part of #713

For testing

To fake the size of a file you can overwrite the line 168 of the src/static/js/ours/client.js file

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

@ihsaan-ullah

Copy link
Copy Markdown
Collaborator Author

My tests

It looks like we don't have the quota branch on codabench. I have cloned Tristan's repo and chekedout the quota branch to do the test.

Admin Interface

  • ✅ Quota field is visible in the user table on admin interface
    Screenshot 2023-12-13 at 3 28 54 PM.

  • ✅ Changing the value in this field is reflected in the resource interface

  • ✅ default value is set to 15GB

Resource Interface

  • ✅ total quota and used quota is visible in the resource interface
Screenshot 2023-12-13 at 3 31 13 PM
  • ✅ Changing the user quota from admin interface is reflected in the resource interface
Screenshot 2023-12-13 at 3 31 20 PM
  • ❌ uploading new dataset/submission/program from resource interface does not refresh the quota to show updated used quota

Limit check

  • ✅ Uploading submission when the limit is reached gives error
Screenshot 2023-12-13 at 3 41 22 PM
  • ✅ Uploading dataset/program when the limit is reached gives error
Screenshot 2023-12-13 at 3 41 47 PM
  • ✅ Uploading competition when the limit is reached gives error
Screenshot 2023-12-13 at 3 42 04 PM

Manual validation (https://github.com/codalab/codabench/wiki/manual-validation)

  • Create an user account and login
  • Create a competition
  • Create a queue
  • Upload a submission
  • Check that the submission was processed (results, visualization tab, leaderboard)
  • Change/recover password
  • Delete user
    Attempted to delete user from admin interface. Failed with this error:
django.db.utils.IntegrityError: insert or update on table "tasks_task" violates foreign key constraint "tasks_task_created_by_id_1345568a_fk_profiles_user_id"
DETAIL:  Key (created_by_id)=(2) is not present in table "profiles_user".
  • Delete submission
  • Delete queue
  • Delete competition
  • Admin page
  • Look at the logs for any problematic messages (docker-compose logs -f)

Suggestions:

  1. Refresh the interface automatically when submisison/dataset is uploaded in resource interface
  2. Readable format for the quota in the user table .e.g MB

@Didayolo

Didayolo commented Dec 14, 2023

Copy link
Copy Markdown
Member

The last point is to add some documentation, especially in "admin procedure" (documentation about how to change the quota of users).

https://github.com/codalab/codabench/wiki/Administrator-procedures

@Didayolo Didayolo mentioned this pull request Dec 14, 2023
43 tasks
@ihsaan-ullah

Copy link
Copy Markdown
Collaborator Author

The last point is to add some documentation, especially in "admin procedure" (documentation about how to change the quota of users).

https://github.com/codalab/codabench/wiki/Administrator-procedures

Updated:
https://github.com/codalab/codabench/wiki/Administrator-procedures#user-quota-management

@ihsaan-ullah

Copy link
Copy Markdown
Collaborator Author

There are some migration problems. I will check it in detail and try to fix

@Didayolo

Copy link
Copy Markdown
Member

@ihsaan-ullah Maybe it can be easier to first fix develop in a separate pull request?

We are not sure if the migration problems come from the last PR (monitoring), this one, or the combination of the two.

@ihsaan-ullah

Copy link
Copy Markdown
Collaborator Author

@OhMaley

One automated test is failing because of the new addition of file_size

This is the test:

def test_dataset_api_checks_duplicate_names_for_same_user(self):

This is the line where it fails:

file_size = float(request.data['file_size'])

@ihsaan-ullah ihsaan-ullah merged commit f5f17f2 into develop Dec 21, 2023
@ihsaan-ullah ihsaan-ullah deleted the user-quota branch December 21, 2023 16:43
This was referenced Jan 9, 2024
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