Skip to content

Commit 6730c7f

Browse files
committed
Small tweaks
1 parent 0a7c9af commit 6730c7f

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

backend/btrixcloud/crawls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ async def get_active_crawls(self, oid: UUID, limit: int) -> list[str]:
365365
res_list = await res.to_list()
366366
return [res["_id"] for res in res_list]
367367

368-
async def get_active_crawls_size(self, oid: UUID) -> int:
369-
"""get size of all active (running, waiting, paused) crawls"""
368+
async def get_active_crawls_pending_size(self, oid: UUID) -> int:
369+
"""get pending size of all active (running, waiting, paused) crawls"""
370370
cursor = self.crawls.aggregate(
371371
[
372372
{"$match": {"state": {"$in": RUNNING_AND_WAITING_STATES}, "oid": oid}},

backend/btrixcloud/operator/crawls.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ async def sync_crawls(self, data: MCSyncData):
396396
if status.pagesFound < status.desiredScale:
397397
status.desiredScale = max(1, status.pagesFound)
398398

399-
# paused and shut down pods if size is <= 4096 (empty dir)
400-
# paused_at is set state is a valid paused state
399+
# paused and shut down pods if size is <= 4096 (empty dir),
400+
# paused_at is set, and state is a valid paused state
401401
is_paused = (
402402
bool(crawl.paused_at)
403403
and status.sizePending <= 4096
@@ -1463,14 +1463,11 @@ async def is_crawl_stopping(
14631463

14641464
# pause crawl if storage quota is reached
14651465
if org.quotas.storageQuota:
1466-
# Make sure to account for already-uploaded WACZs from active crawls
1467-
# that are or previously were paused, which are already accounted for
1468-
# in the org storage stats
1469-
active_crawls_total_size = await self.crawl_ops.get_active_crawls_size(
1470-
crawl.oid
1466+
# include not-yet-uploaded pending data from all active crawls
1467+
active_crawls_pending_size = (
1468+
await self.crawl_ops.get_active_crawls_pending_size(crawl.oid)
14711469
)
1472-
1473-
if self.org_ops.storage_quota_reached(org, active_crawls_total_size):
1470+
if self.org_ops.storage_quota_reached(org, active_crawls_pending_size):
14741471
return self.request_pause_crawl("paused_storage_quota_reached", crawl)
14751472

14761473
# pause crawl if execution time quota is reached

0 commit comments

Comments
 (0)