File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
backend/btrixcloud/operator Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 19
19
TYPE_NON_RUNNING_STATES ,
20
20
TYPE_RUNNING_STATES ,
21
21
TYPE_ALL_CRAWL_STATES ,
22
- NON_RUNNING_STATES ,
23
22
RUNNING_STATES ,
24
23
WAITING_STATES ,
25
24
RUNNING_AND_STARTING_ONLY ,
@@ -757,22 +756,22 @@ async def can_start_new(
757
756
if not max_crawls :
758
757
return True
759
758
760
- if len (data .related [CJS ]) <= max_crawls :
761
- return True
762
-
763
759
name = data .parent .get ("metadata" , {}).get ("name" )
764
760
765
- i = 0
761
+ active_crawls = 0
762
+
766
763
for crawl_sorted in data .related [CJS ].values ():
767
- if crawl_sorted .get ("status" , {}).get ("state" ) in NON_RUNNING_STATES :
764
+ crawl_state = crawl_sorted .get ("status" , {}).get ("state" , "" )
765
+
766
+ # don't count ourselves
767
+ if crawl_sorted .get ("metadata" , {}).get ("name" ) == name :
768
768
continue
769
769
770
- if crawl_sorted .get ("metadata" ).get ("name" ) == name :
771
- if i < max_crawls :
772
- return True
770
+ if crawl_state in RUNNING_AND_WAITING_STATES :
771
+ active_crawls += 1
773
772
774
- break
775
- i += 1
773
+ if active_crawls <= max_crawls :
774
+ return True
776
775
777
776
await self .set_state (
778
777
"waiting_org_limit" , status , crawl , allowed_from = ["starting" ]
You can’t perform that action at this time.
0 commit comments