Admission gate for a rename: RenameGate in flow/rename.py, installed by main.AdmissionGate inside CORS, turns mutating API requests away with 503 renaming and Retry-After while closed and drains those admitted without a limit, abortable; affected flows' hooks get 503 or socket close 1013, reads, sign-in, assistant, workers, artifacts and rename routes pass; the run cache misses while the gate is closed; trigger_node lets EngineHeld through instead of reporting a node failure
This commit is contained in:
@@ -813,6 +813,7 @@ class RunCache:
|
||||
self,
|
||||
artifacts: ArtifactStore | None = None,
|
||||
key_of: Callable[[str], str] | None = None,
|
||||
renaming: Callable[[], bool] | None = None,
|
||||
) -> None:
|
||||
self.artifacts = artifacts
|
||||
#: The key a source run's outputs are named with, from its flow's id:
|
||||
@@ -820,9 +821,13 @@ class RunCache:
|
||||
#: one the id is taken for the key, which it is for a flow from before
|
||||
#: ids.
|
||||
self.key_of = key_of or (lambda flow_id: flow_id)
|
||||
#: Whether a rename is under way, which may have moved some of a
|
||||
#: source run's output names and not yet the others. Every lookup
|
||||
#: misses meanwhile, which only costs running the node.
|
||||
self.renaming = renaming or (lambda: False)
|
||||
|
||||
def lookup(self, key: str) -> CacheHit | None:
|
||||
if not key:
|
||||
if not key or self.renaming():
|
||||
return None
|
||||
try:
|
||||
with Session(db_engine) as session:
|
||||
@@ -874,12 +879,15 @@ class RunService:
|
||||
state_factory: Callable[[str], StateBackend] | None = None,
|
||||
parallel: int = MAX_PARALLEL,
|
||||
artifacts: ArtifactStore | None = None,
|
||||
renaming: Callable[[], bool] | None = None,
|
||||
) -> None:
|
||||
self.controller = controller
|
||||
self.queue = queue
|
||||
self._artifacts = artifacts
|
||||
self._cache = RunCache(
|
||||
artifacts, lambda flow_id: tombstones.name_of(flow_id, controller.store)
|
||||
artifacts,
|
||||
lambda flow_id: tombstones.name_of(flow_id, controller.store),
|
||||
renaming,
|
||||
)
|
||||
# Without one, a run gets a private in-memory state — which is exactly
|
||||
# the isolation it wants, minus surviving the process.
|
||||
|
||||
Reference in New Issue
Block a user