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

[24.1] Fix quota check for advanced object store configurations #19589

Draft
wants to merge 1 commit into
base: release_24.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions lib/galaxy/quota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_usage(self, trans=None, user=False, history=False, quota_source_label=No
usage = quota_source_usage.disk_usage
return usage

def is_over_quota(self, app, job, job_destination):
def is_over_quota(self, app, job):
"""Return True if the user or history is over quota for specified job.

job_destination unused currently but an important future application will
Expand Down Expand Up @@ -102,7 +102,7 @@ def get_percent(
) -> Optional[int]:
return None

def is_over_quota(self, app, job, job_destination):
def is_over_quota(self, app, job):
return False


Expand Down Expand Up @@ -378,16 +378,12 @@ def set_entity_quota_associations(self, quotas=None, users=None, groups=None, de
with transaction(self.sa_session):
self.sa_session.commit()

def is_over_quota(self, app, job, job_destination):
def is_over_quota(self, app, job):
if is_user_object_store(job.object_store_id):
return False # User object stores are not subject to quotas
if job_destination is not None:
object_store_id = job_destination.params.get("object_store_id", None)
object_store = app.object_store
quota_source_map = object_store.get_quota_source_map()
quota_source_label = quota_source_map.get_quota_source_info(object_store_id).label
else:
quota_source_label = None
object_store = app.object_store
quota_source_map = object_store.get_quota_source_map()
quota_source_label = quota_source_map.get_quota_source_info(job.object_store_id).label
quota = self.get_quota(job.user, quota_source_label=quota_source_label)
if quota is not None:
try:
Expand Down
6 changes: 3 additions & 3 deletions test/unit/data/test_quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ def _assert_user_quota_is(self, user, amount, quota_source_label=None):
user.total_disk_usage = 1000
job = self.model.Job()
job.user = user
assert not self.quota_agent.is_over_quota(None, job, None)
assert not self.quota_agent.is_over_quota(None, job)
else:
job = self.model.Job()
job.user = user
user.total_disk_usage = amount - 1
assert not self.quota_agent.is_over_quota(None, job, None)
assert not self.quota_agent.is_over_quota(None, job)
user.total_disk_usage = amount + 1
assert self.quota_agent.is_over_quota(None, job, None)
assert self.quota_agent.is_over_quota(None, job)


class TestUsage(BaseModelTestCase):
Expand Down
Loading