workspace: stop worker before cleanup delete
This commit is contained in:
parent
f5b200d36b
commit
34856b9900
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: 'Stop Worker before cleanup deletion'
|
||||
state: 'inprogress'
|
||||
state: 'done'
|
||||
created_at: '2026-07-13T13:58:15Z'
|
||||
updated_at: '2026-07-13T13:58:54Z'
|
||||
updated_at: '2026-07-13T14:05:35Z'
|
||||
assignee: null
|
||||
queued_by: 'yoi ticket'
|
||||
queued_at: '2026-07-13T13:58:54Z'
|
||||
|
|
|
|||
|
|
@ -39,4 +39,45 @@ Ticket を `yoi ticket` が queued にしました。
|
|||
State changed to `inprogress`.
|
||||
|
||||
|
||||
---
|
||||
|
||||
<!-- event: implementation_report author: hare at: 2026-07-13T14:05:35Z -->
|
||||
|
||||
## Implementation report
|
||||
|
||||
Changed Worker cleanup execution to stop the selected Worker before Runtime deletion.
|
||||
|
||||
Root cause:
|
||||
- Runtime `delete_worker` rejects active Workers with `worker <id> is running and must be stopped before deletion`.
|
||||
- The cleanup plan can present a Worker as cleanup-eligible when the browser-facing projected state is not `running` (for example execution rejected/unconnected) while Runtime status is still active.
|
||||
- Cleanup execution previously called Runtime delete directly, causing `workspace_cleanup_worker_runtime_delete_rejected`.
|
||||
|
||||
Changes:
|
||||
- `cleanup_runtime_worker_for_execution` now calls `stop_worker` first with a cleanup reason.
|
||||
- If stop is rejected, the cleanup fails with `workspace_cleanup_worker_runtime_stop_rejected` and preserves Runtime diagnostics.
|
||||
- Only after accepted stop does cleanup call Runtime delete and then delete the Backend registry row.
|
||||
- Unknown-worker during stop/delete remains idempotent for stale Backend registry cleanup.
|
||||
|
||||
Manual observation:
|
||||
- Direct Runtime DELETE for worker 1 returned HTTP 400: `worker 1 is running and must be stopped before deletion`.
|
||||
- Direct Runtime stop followed by delete succeeded, confirming the required operation sequence.
|
||||
|
||||
Validation:
|
||||
- `cargo fmt --check`
|
||||
- `git diff --check`
|
||||
- `cargo check -q`
|
||||
- `cargo test -q -p yoi-workspace-server`
|
||||
- targeted cleanup execution test
|
||||
- `nix build .#yoi --no-link`
|
||||
|
||||
|
||||
---
|
||||
|
||||
<!-- event: state_changed author: "yoi ticket" at: 2026-07-13T14:05:35Z from: inprogress to: done reason: cli_state field: state -->
|
||||
|
||||
## State changed
|
||||
|
||||
State changed to `done`.
|
||||
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -2024,6 +2024,28 @@ fn cleanup_runtime_worker_for_execution(
|
|||
runtime_id: &str,
|
||||
candidate: &CleanupWorkerCandidate,
|
||||
) -> ApiResult<()> {
|
||||
match api.runtime.stop_worker(
|
||||
runtime_id,
|
||||
candidate.runtime_worker_id.as_str(),
|
||||
WorkerLifecycleRequest {
|
||||
reason: Some("cleanup worker before deletion".to_string()),
|
||||
},
|
||||
) {
|
||||
Ok(result) if result.state == WorkerOperationState::Accepted => {}
|
||||
Ok(result) => {
|
||||
return Err(ApiError::with_diagnostics(
|
||||
Error::RuntimeOperationFailed {
|
||||
runtime_id: runtime_id.to_string(),
|
||||
code: "workspace_cleanup_worker_runtime_stop_rejected".to_string(),
|
||||
message: "Runtime did not stop selected Worker before deletion".to_string(),
|
||||
},
|
||||
result.diagnostics,
|
||||
));
|
||||
}
|
||||
Err(RuntimeRegistryError::UnknownWorker { .. }) => return Ok(()),
|
||||
Err(error) => return Err(error.into_error().into()),
|
||||
}
|
||||
|
||||
match api
|
||||
.runtime
|
||||
.delete_worker(runtime_id, candidate.runtime_worker_id.as_str())
|
||||
|
|
@ -2033,7 +2055,7 @@ fn cleanup_runtime_worker_for_execution(
|
|||
Error::RuntimeOperationFailed {
|
||||
runtime_id: runtime_id.to_string(),
|
||||
code: "workspace_cleanup_worker_runtime_delete_rejected".to_string(),
|
||||
message: "Runtime did not delete selected Worker".to_string(),
|
||||
message: "Runtime did not delete selected Worker after stopping it".to_string(),
|
||||
},
|
||||
result.diagnostics,
|
||||
)),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user