feat(guard): read the Zerto task, and ask before guarding unknown tools (#6)
This commit was merged in pull request #6.
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import Any
|
||||
|
||||
from zerto_rewind_mcp.client import ZertoClient, ZertoError
|
||||
from zerto_rewind_mcp.protection import FindResult
|
||||
from zerto_rewind_mcp.tasks import task_id_from, wait_for_task
|
||||
from zerto_rewind_mcp.util import pick
|
||||
|
||||
_CTRL = re.compile(r"[\x00-\x1f\x7f]+")
|
||||
@@ -108,16 +109,20 @@ async def tag_vpgs(
|
||||
"message": result.message,
|
||||
"find": result.as_dict(),
|
||||
}
|
||||
# Insert then wait, one VPG at a time. Measured on 10.x: tagged checkpoint
|
||||
# inserts fired back to back at the same VPG are silently dropped -- the POST
|
||||
# returns 200 and queues a task, but only the first checkpoint ever appears.
|
||||
# Do not turn this loop into an asyncio.gather().
|
||||
# Insert then wait for the TASK, one VPG at a time. The POST returns a task
|
||||
# id, not a result: 200 only means queued. Measured on 10.x, a second insert
|
||||
# fired at the same VPG while the first is running comes back Failed (state
|
||||
# 4) from GET /v1/tasks/{id} while the first is Completed (6). That failure
|
||||
# is reported, not silent -- but only if you read the task. Do not turn this
|
||||
# loop into an asyncio.gather().
|
||||
tagged: list[dict[str, Any]] = []
|
||||
skipped = [v.as_dict() for v in result.vm.vpgs if not v.can_tag]
|
||||
errors: list[str] = []
|
||||
for vpg in result.taggable_vpgs:
|
||||
try:
|
||||
insert = await client.insert_checkpoint(vpg.vpg_identifier, tag)
|
||||
task_id = task_id_from(insert)
|
||||
task = await wait_for_task(client, task_id)
|
||||
row = await wait_for_tag(client, vpg.vpg_identifier, tag)
|
||||
tagged.append(
|
||||
{
|
||||
@@ -125,7 +130,8 @@ async def tag_vpgs(
|
||||
"vpg_name": vpg.vpg_name,
|
||||
"checkpoint_id": checkpoint_id(row),
|
||||
"tag": checkpoint_tag(row) or tag,
|
||||
"insert_result": insert if not isinstance(insert, dict) else "ok",
|
||||
"task_id": task_id,
|
||||
"task_state": task["label"],
|
||||
}
|
||||
)
|
||||
except ZertoError as exc:
|
||||
|
||||
Reference in New Issue
Block a user