feat: add tag assignment deletion and improve agent error handling in provisioning
This commit is contained in:
@@ -22,6 +22,7 @@ from app.models.board_webhook_payloads import BoardWebhookPayload
|
|||||||
from app.models.board_webhooks import BoardWebhook
|
from app.models.board_webhooks import BoardWebhook
|
||||||
from app.models.organization_board_access import OrganizationBoardAccess
|
from app.models.organization_board_access import OrganizationBoardAccess
|
||||||
from app.models.organization_invite_board_access import OrganizationInviteBoardAccess
|
from app.models.organization_invite_board_access import OrganizationInviteBoardAccess
|
||||||
|
from app.models.tag_assignments import TagAssignment
|
||||||
from app.models.task_dependencies import TaskDependency
|
from app.models.task_dependencies import TaskDependency
|
||||||
from app.models.task_fingerprints import TaskFingerprint
|
from app.models.task_fingerprints import TaskFingerprint
|
||||||
from app.models.tasks import Task
|
from app.models.tasks import Task
|
||||||
@@ -64,6 +65,14 @@ async def delete_board(session: AsyncSession, *, board: Board) -> OkResponse:
|
|||||||
col(ActivityEvent.task_id).in_(task_ids),
|
col(ActivityEvent.task_id).in_(task_ids),
|
||||||
commit=False,
|
commit=False,
|
||||||
)
|
)
|
||||||
|
await crud.delete_where(
|
||||||
|
session,
|
||||||
|
TagAssignment,
|
||||||
|
col(TagAssignment.task_id).in_(task_ids),
|
||||||
|
commit=False,
|
||||||
|
)
|
||||||
|
# Keep teardown ordered around FK/reference chains so dependent rows are gone
|
||||||
|
# before deleting their parent task/agent/board records.
|
||||||
await crud.delete_where(
|
await crud.delete_where(
|
||||||
session,
|
session,
|
||||||
TaskDependency,
|
TaskDependency,
|
||||||
|
|||||||
@@ -73,6 +73,15 @@ def _is_missing_session_error(exc: OpenClawGatewayError) -> bool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _is_missing_agent_error(exc: OpenClawGatewayError) -> bool:
|
||||||
|
message = str(exc).lower()
|
||||||
|
if not message:
|
||||||
|
return False
|
||||||
|
if any(marker in message for marker in ("unknown agent", "no such agent", "agent does not exist")):
|
||||||
|
return True
|
||||||
|
return "agent" in message and "not found" in message
|
||||||
|
|
||||||
|
|
||||||
def _repo_root() -> Path:
|
def _repo_root() -> Path:
|
||||||
return Path(__file__).resolve().parents[3]
|
return Path(__file__).resolve().parents[3]
|
||||||
|
|
||||||
@@ -880,7 +889,11 @@ class OpenClawGatewayProvisioner:
|
|||||||
agent_gateway_id = GatewayAgentIdentity.openclaw_agent_id(gateway)
|
agent_gateway_id = GatewayAgentIdentity.openclaw_agent_id(gateway)
|
||||||
else:
|
else:
|
||||||
agent_gateway_id = _agent_key(agent)
|
agent_gateway_id = _agent_key(agent)
|
||||||
await control_plane.delete_agent(agent_gateway_id, delete_files=delete_files)
|
try:
|
||||||
|
await control_plane.delete_agent(agent_gateway_id, delete_files=delete_files)
|
||||||
|
except OpenClawGatewayError as exc:
|
||||||
|
if not _is_missing_agent_error(exc):
|
||||||
|
raise
|
||||||
|
|
||||||
if delete_session:
|
if delete_session:
|
||||||
if agent.board_id is None:
|
if agent.board_id is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user