workspace: stabilize cleanup plan digest

This commit is contained in:
Keisuke Hirata 2026-07-13 22:38:35 +09:00
parent 655cdf9533
commit 498337317c
No known key found for this signature in database
3 changed files with 44 additions and 2 deletions

View File

@ -1,8 +1,8 @@
--- ---
title: 'Stabilize cleanup plan ordering' title: 'Stabilize cleanup plan ordering'
state: 'inprogress' state: 'done'
created_at: '2026-07-13T13:29:51Z' created_at: '2026-07-13T13:29:51Z'
updated_at: '2026-07-13T13:30:39Z' updated_at: '2026-07-13T13:38:25Z'
assignee: null assignee: null
queued_by: 'yoi ticket' queued_by: 'yoi ticket'
queued_at: '2026-07-13T13:30:39Z' queued_at: '2026-07-13T13:30:39Z'

View File

@ -39,4 +39,44 @@ Ticket を `yoi ticket` が queued にしました。
State changed to `inprogress`. State changed to `inprogress`.
---
<!-- event: implementation_report author: hare at: 2026-07-13T13:38:25Z -->
## Implementation report
Stabilized cleanup plan candidate ordering and verified the not-found Workdir deletion endpoint.
Root cause:
- Cleanup plan digest includes worker/workdir candidate arrays.
- Candidate order was not normalized before digest calculation, so GET `/cleanup-plan` and POST `/cleanup-executions` could compute different digests for the same target set.
- The POST then failed with `workspace_cleanup_plan_stale`, preventing `workdir_record_delete` execution.
Changes:
- Sort worker cleanup candidates by `target_id` before digest calculation.
- Sort Workdir cleanup candidates by `target_id` before digest calculation.
Endpoint verification:
- Fetched `GET /api/w/0197a949-4b6b-7f2a-9d9a-1f87e3a4c5b6/runtimes/arc/cleanup-plan`.
- Posted the returned revision/digest and all `file_status: not_found` Workdir target ids to `POST /cleanup-executions`.
- Received HTTP 200 and four `workdir_record_delete` results with `status: deleted`.
Validation:
- `cargo fmt --check`
- `git diff --check`
- `cargo check -q`
- `cargo test -q -p yoi-workspace-server`
- targeted cleanup plan test
- `nix build .#yoi --no-link`
---
<!-- event: state_changed author: "yoi ticket" at: 2026-07-13T13:38:25Z from: inprogress to: done reason: cli_state field: state -->
## State changed
State changed to `done`.
--- ---

View File

@ -1810,6 +1810,8 @@ fn build_runtime_cleanup_plan(
estimated_reclaim_bytes: None, estimated_reclaim_bytes: None,
}); });
} }
worker_candidates.sort_by(|left, right| left.target_id.cmp(&right.target_id));
workdir_candidates.sort_by(|left, right| left.target_id.cmp(&right.target_id));
diagnostics.truncate(16); diagnostics.truncate(16);
let generated_at = now_registry_timestamp(); let generated_at = now_registry_timestamp();
let digest = cleanup_plan_digest(&worker_candidates, &workdir_candidates)?; let digest = cleanup_plan_digest(&worker_candidates, &workdir_candidates)?;