Skip to content

Commit 2df69bb

Browse files
committed
simplify, just get fail_reason directly from redis if failed
1 parent 5ccd39a commit 2df69bb

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

backend/btrixcloud/operator/crawls.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,14 @@ async def fail_crawl(
828828
status: CrawlStatus,
829829
pods: dict,
830830
stats: Optional[CrawlStats] = None,
831+
fail_reason: Optional[str] = "",
831832
) -> bool:
832833
"""Mark crawl as failed, log crawl state and print crawl logs, if possible"""
833834
prev_state = status.state
834835

835836
failed_state: Literal["failed", "failed_not_logged_in"] = "failed"
836837

837-
if status.failReason and status.failReason == "not_logged_in":
838+
if fail_reason == "not_logged_in":
838839
failed_state = "failed_not_logged_in"
839840

840841
if not await self.mark_finished(crawl, status, failed_state, stats=stats):
@@ -1496,8 +1497,6 @@ async def update_crawl_state(
14961497
status.size = stats.size
14971498
status.sizeHuman = humanize.naturalsize(status.size)
14981499

1499-
status.failReason = await redis.get(f"{crawl.id}:failReason")
1500-
15011500
await self.crawl_ops.update_running_crawl_stats(
15021501
crawl.db_crawl_id, crawl.is_qa, stats
15031502
)
@@ -1612,7 +1611,9 @@ async def update_crawl_state(
16121611
if status.stopping and not status.pagesDone:
16131612
await self.mark_finished(crawl, status, "canceled", stats)
16141613
else:
1615-
await self.fail_crawl(crawl, status, pods, stats)
1614+
fail_reason = await redis.get(f"{crawl.id}:failReason")
1615+
1616+
await self.fail_crawl(crawl, status, pods, stats, fail_reason)
16161617

16171618
# check for other statuses, default to "running"
16181619
else:

backend/btrixcloud/operator/models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ class CrawlStatus(BaseModel):
233233
restartTime: Optional[str] = None
234234
canceled: bool = False
235235

236-
failReason: Optional[str] = None
237-
238236
# updated on pod exits and at regular interval
239237
# Crawl Execution Time -- time all crawler pods have been running
240238
# used to track resource usage and enforce execution minutes limit

0 commit comments

Comments
 (0)