|
51 | 51 | POD, |
52 | 52 | CMAP, |
53 | 53 | PVC, |
54 | | - CJS, |
55 | 54 | ) |
56 | 55 |
|
57 | 56 |
|
@@ -1031,7 +1030,7 @@ async def sync_crawl_state( |
1031 | 1030 |
|
1032 | 1031 | # update stats and get status |
1033 | 1032 | return await self.update_crawl_state( |
1034 | | - redis, crawl, status, pods, pod_done_count, data |
| 1033 | + redis, crawl, status, pods, pod_done_count |
1035 | 1034 | ) |
1036 | 1035 |
|
1037 | 1036 | # pylint: disable=broad-except |
@@ -1397,7 +1396,7 @@ async def add_file_to_crawl(self, cc_data, crawl: CrawlSpec, redis): |
1397 | 1396 | return True |
1398 | 1397 |
|
1399 | 1398 | async def is_crawl_stopping( |
1400 | | - self, crawl: CrawlSpec, status: CrawlStatus, data: MCSyncData |
| 1399 | + self, crawl: CrawlSpec, status: CrawlStatus |
1401 | 1400 | ) -> Optional[StopReason]: |
1402 | 1401 | """check if crawl is stopping and set reason""" |
1403 | 1402 | # if user requested stop, then enter stopping phase |
@@ -1428,19 +1427,11 @@ async def is_crawl_stopping( |
1428 | 1427 | return "stopped_org_readonly" |
1429 | 1428 |
|
1430 | 1429 | if org.quotas.storageQuota: |
1431 | | - running_crawls_total_size = status.size |
1432 | | - for crawl_job in data.related[CJS].values(): |
1433 | | - # if the job id matches current crawl job, then skip |
1434 | | - # this job to avoid double-counting |
1435 | | - # using the more up-to-date 'status.size' for this job |
1436 | | - if crawl_job.get("spec", {}).get("id") == crawl.id: |
1437 | | - continue |
1438 | | - |
1439 | | - crawl_status = crawl_job.get("status", {}) |
1440 | | - if crawl_status: |
1441 | | - running_crawls_total_size += crawl_status.get("size", 0) |
| 1430 | + active_crawls_total_size = await self.crawl_ops.get_active_crawls_size( |
| 1431 | + crawl.oid |
| 1432 | + ) |
1442 | 1433 |
|
1443 | | - if self.org_ops.storage_quota_reached(org, running_crawls_total_size): |
| 1434 | + if self.org_ops.storage_quota_reached(org, active_crawls_total_size): |
1444 | 1435 | return "stopped_storage_quota_reached" |
1445 | 1436 |
|
1446 | 1437 | # gracefully stop crawl is execution time quota is reached |
@@ -1479,7 +1470,6 @@ async def update_crawl_state( |
1479 | 1470 | status: CrawlStatus, |
1480 | 1471 | pods: dict[str, dict], |
1481 | 1472 | pod_done_count: int, |
1482 | | - data: MCSyncData, |
1483 | 1473 | ) -> CrawlStatus: |
1484 | 1474 | """update crawl state and check if crawl is now done""" |
1485 | 1475 | results = await redis.hgetall(f"{crawl.id}:status") |
@@ -1536,7 +1526,7 @@ async def update_crawl_state( |
1536 | 1526 | await redis.delete(f"{crawl.id}:paused") |
1537 | 1527 |
|
1538 | 1528 | if not status.stopping: |
1539 | | - status.stopReason = await self.is_crawl_stopping(crawl, status, data) |
| 1529 | + status.stopReason = await self.is_crawl_stopping(crawl, status) |
1540 | 1530 | status.stopping = status.stopReason is not None |
1541 | 1531 |
|
1542 | 1532 | # mark crawl as stopping |
|
0 commit comments