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

Quota manager for GCS #2084

Merged
merged 3 commits into from
Sep 22, 2023
Merged

Quota manager for GCS #2084

merged 3 commits into from
Sep 22, 2023

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented Sep 21, 2023

Today's yak-shaving has brought me to the fact that the GCS storage backend never properly implemented the SubmissionInfo.quota_manager method.

(Want to know what quota_manager is about? See #1003 (comment) and issue #518)

This pull request rearranges logic a bit but shouldn't have any functional changes - storage usage is still measured by calling GCSObject.size.

This is necessary for exciting and wonderful things in the future.

@bemoody
Copy link
Collaborator Author

bemoody commented Sep 22, 2023

Late last night I realized that despite how little functional code there is here, I still managed to make a small mistake. That's why we need test cases ;)

Benjamin Moody added 3 commits September 22, 2023 09:40
This class implements the basic QuotaManager API for the Google Cloud
Storage backend.

(Note the SubmissionInfo.quota_manager method is currently broken for
GCS - and always has been, since GCS was introduced.)

Note that GCS doesn't (as far as I know) provide any way to limit the
storage usage of a bucket or a project, let alone the usage of a
particular prefix within a bucket.  (I also don't know how Google
calculates the cost of storing objects in GCS, but obviously there is
some storage used for metadata in addition to the object content.)

I also don't know if there is any way to report the storage usage of a
bucket or prefix in any meaningful way, other than by actually
iterating over all the blobs in the bucket as GCSObject.size does.

So GCSQuotaManager calculates bytes_used in the same inefficient way
as GCSProjectFiles.active_project_storage_used (which this class is
intended to replace.)

Currently it does *not* calculate inodes_used (though that should be
easy enough to do, it should ideally be done by GCSObject and avoid
making more unnecessary requests.)

GCSQuotaManager also implements the other QuotaManager methods, such
as create_toplevel_directory and check_create_file, in much the same
way that DemoQuotaManager does, so that we can eventually use the
QuotaManager API in other areas of the code.
Quota management behavior depends on the project file storage.  For
GCS storage, a GCSQuotaManager is required.

(Until now, the SubmissionInfo.quota_manager method has been broken on
GCS, and the GCS backend has carefully avoided using this API - which
unfortunately has also blocked development of the quota system.)

Rather than including this logic in SubmissionInfo, it seemingly makes
more sense for quota policy to be part of ProjectFiles; so a new
abstract method 'project_quota_manager' is defined.
The 'active_project_storage_used' method is used to report "how much
of the storage allowance for the given project submission has been
used."

(The name suggests that this is somehow similar to
'published_project_storage_used', but this is not the case: *that*
method is used to inform visitors "how large will the project files be
if I download all of them", which is only tangentially related to the
resource usage that a particular submission is responsible for.)

Reporting (as well as limiting) resource usage is the task of the
QuotaManager.  Use the QuotaManager API and remove the redundant
ProjectFiles API.
@tompollard
Copy link
Member

Thanks Benjamin, looking forward to seeing where this is going!

@tompollard tompollard merged commit 933aef9 into dev Sep 22, 2023
8 checks passed
@tompollard tompollard deleted the gcs-quota-manager branch September 22, 2023 20:59
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.

2 participants