Rename orchestration, splice and routes: a Renamer runs one rename at a time, closing the gate, taking the controller lock and holding the engine, each waiting without a limit and saying what it waits for (summary rename status, rename_waiting); DELETE on the pending request or a closed connection calls it off until the journal begins (409 aborted); then journal, steps and audit, retried in the background on failure (503 completing); splice_renamed rebuilds the affected flows under the held lock keeping stopped, paused and parked work, history limits and device wiring refreshed before activation; AlertManager.rename and EventBus.rename/settle follow the names; flow and dashboard rename routes answer by code and repeat stored results; renamed, dashboard_changed and pipeline_rebuilt after release; fluksio serve reads flow files without building a FlowStore

This commit is contained in:
2026-11-02 22:14:44 +01:00
parent 2d65118d82
commit ba4aae390d
16 changed files with 2174 additions and 22 deletions
+62 -1
View File
@@ -35,6 +35,7 @@ from fluksio.api.deps import (
DashboardStoreDep,
FlowControllerDep,
HiddenDep,
RenamerDep,
SessionDep,
TokenDep,
check_pin,
@@ -69,7 +70,13 @@ from fluksio.flow.events import event_bus
from fluksio.flow.messages import MEDIA_FAMILIES, DType, flow_of, qualify
from fluksio.flow.nodes.wren import TRAIN_FLOW, WrenNode, pack_meta
from fluksio.flow.pipeline import EngineHeld, ValidationIssue
from fluksio.flow.rename import RenamePlan, RenamePlanRequest, plan_rename
from fluksio.flow.rename import (
RenamePlan,
RenamePlanRequest,
RenameRequest,
RenameResult,
plan_rename,
)
from fluksio.flow.runs import RunRejected
from fluksio.flow.schemas import (
NAME_PATTERN,
@@ -776,6 +783,60 @@ async def plan_flow_rename(
raise _missing(flow_id)
@router.post(
"/{flow_id}/rename",
response_model=RenameResult,
dependencies=[Depends(get_current_active_superuser)],
)
async def rename_flow(
flow_id: str,
body: RenameRequest,
request: Request,
renamer: RenamerDep,
user: CurrentUser,
) -> Any:
"""Rename this flow's key, as its plan described it.
Everything named under the key moves: every flow and dashboard binding
one of its messages, its history, live state and queued work. The engine
waits meanwhile, for as long as the work running when it was asked takes
to finish. Until then it can be called off, with ``DELETE`` on the
request or by closing the connection, and nothing changes (409
``aborted``); ``GET /observability/summary`` says what it waits for.
The same ``request_id`` again gets the same answer. A rename that
could not finish yet answers 503 ``completing`` and is finished in the
background. Refusals are the plan's codes (409, 422 for a key that is no
key), ``stale`` and ``plan_changed`` (409).
"""
try:
return await renamer.rename(
"flow", flow_id, body, user.email, request.is_disconnected
)
except FlowNotFound:
raise _missing(flow_id)
@router.delete(
"/{flow_id}/rename/{request_id}",
response_model=Message,
dependencies=[Depends(get_current_active_superuser)],
)
async def cancel_flow_rename(flow_id: str, request_id: str, renamer: RenamerDep) -> Any:
"""Call off a rename still waiting for the engine. It answers 409
``aborted`` once everything is as it was, and one that has begun to
change things refuses this with 409 ``too_late``."""
# Async, so on the event loop, where the rename decides when it is past
# calling off.
try:
renamer.cancel(flow_id, request_id)
except KeyError:
raise HTTPException(
status_code=404, detail=f"No rename '{request_id}' of '{flow_id}' waits"
)
return Message(message=f"Calling off rename '{request_id}'")
# -----------------------------------------------------------------------------
# Node source
# -----------------------------------------------------------------------------