Skip to content

Commit e9aeff1

Browse files
authored
add a 'stopped_org_readonly' state for crawls that are running while org is made read-only (#1977)
an org is made read-only while crawls are running: - treat similar to other stopped_* states, do a graceful stop - update UI to display "Stopped: Crawling Disabled" for this status - don't add corresponding skipped status - just skip running crawls if org is read-only
1 parent 96691a3 commit e9aeff1

File tree

6 files changed

+20
-1
lines changed

6 files changed

+20
-1
lines changed

backend/btrixcloud/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class UserOut(BaseModel):
224224
"stopped_by_user",
225225
"stopped_storage_quota_reached",
226226
"stopped_time_quota_reached",
227+
"stopped_org_readonly",
227228
]
228229
SUCCESSFUL_STATES = get_args(TYPE_SUCCESSFUL_STATES)
229230

backend/btrixcloud/operator/crawls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,9 @@ async def is_crawl_stopping(
12421242
# gracefully stop crawl if current running crawl sizes reach storage quota
12431243
org = await self.org_ops.get_org_by_id(crawl.oid)
12441244

1245+
if org.readOnly:
1246+
return "stopped_org_readonly"
1247+
12451248
if org.quotas.storageQuota:
12461249
running_crawls_total_size = status.size
12471250
for crawl_job in data.related[CJS].values():
@@ -1366,6 +1369,8 @@ async def update_crawl_state(
13661369
state = "stopped_storage_quota_reached"
13671370
elif status.stopReason == "stopped_time_quota_reached":
13681371
state = "stopped_time_quota_reached"
1372+
elif status.stopReason == "stopped_org_readonly":
1373+
state = "stopped_org_readonly"
13691374
else:
13701375
state = "complete"
13711376

backend/btrixcloud/operator/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"size-limit",
2222
"stopped_storage_quota_reached",
2323
"stopped_time_quota_reached",
24+
"stopped_org_readonly",
2425
]
2526

2627

frontend/src/features/archived-items/crawl-status.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ export class CrawlStatus extends TailwindElement {
228228
label = msg("Stopped: Time Quota Reached");
229229
break;
230230

231+
case "stopped_org_readonly":
232+
color = "var(--warning)";
233+
icon = html`<sl-icon
234+
name="exclamation-square-fill"
235+
slot="prefix"
236+
style="color: ${color}"
237+
></sl-icon>`;
238+
label = msg("Stopped: Crawling Disabled");
239+
break;
240+
231241
case "canceled":
232242
color = "var(--sl-color-orange-600)";
233243
icon = html`<sl-icon

frontend/src/types/crawler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ export type CrawlState =
139139
| "canceled"
140140
| "stopped_by_user"
141141
| "stopped_storage_quota_reached"
142-
| "stopped_time_quota_reached";
142+
| "stopped_time_quota_reached"
143+
| "stopped_org_readonly";
143144

144145
// TODO maybe convert this to an enum?
145146
export enum ReviewStatus {

frontend/src/utils/crawler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const finishedCrawlStates: CrawlState[] = [
2121
"stopped_by_user",
2222
"stopped_storage_quota_reached",
2323
"stopped_time_quota_reached",
24+
"stopped_org_readonly",
2425
];
2526

2627
export const inactiveCrawlStates: CrawlState[] = [

0 commit comments

Comments
 (0)