Skip to content

Commit

Permalink
quota: Fix join on caching repo size (PROJQUAY-3889) (#1381)
Browse files Browse the repository at this point in the history
Method for calculating size of repo joined on repo id instead of manifest id. This causes deleted manifests to be counted. Change updates call to join on manifest id.

Co-authored-by: bcaton <[email protected]>
  • Loading branch information
openshift-cherrypick-robot and bcaton85 authored Jun 14, 2022
1 parent 6090bd0 commit 058b9d3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions data/model/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,16 +733,17 @@ def force_cache_repo_size(repo_id: int):
try:
now_ms = get_epoch_timestamp_ms()
subquery = (
Tag.select(Tag.repository_id)
Tag.select(Tag.manifest)
.where(Tag.hidden == False)
.where((Tag.lifetime_end_ms >> None) | (Tag.lifetime_end_ms > now_ms))
.group_by(Tag.repository_id)
.where(Tag.repository_id == repo_id)
.group_by(Tag.manifest)
.having(fn.Count(Tag.name) > 0)
)

cache = (
Manifest.select(fn.Sum(Manifest.layers_compressed_size).alias("size_bytes"))
.join(subquery, on=(subquery.c.repository_id == Manifest.repository_id))
.join(subquery, on=(subquery.c.manifest_id == Manifest.id))
.where(Manifest.repository == repo_id)
).scalar()

Expand Down

0 comments on commit 058b9d3

Please sign in to comment.