Skip to content

fix(engine): reclaim terminal runs whose workspace disappeared - #1525

Open
wcy12378 wants to merge 1 commit into
Tencent:mainfrom
wcy12378:pi-deepseek/lf1473-workspace-loop
Open

wcy12378 wants to merge 1 commit into
Tencent:mainfrom
wcy12378:pi-deepseek/lf1473-workspace-loop

Conversation

@wcy12378

Copy link
Copy Markdown

fix(engine): reclaim terminal runs whose workspace disappeared

This is the #1473 slice: release the admission slot and stop the endless cleanup sweep when a finished run's runner workspace was removed from the host.

Problem

For a succeeded/cancelled run whose workspace directory was deleted externally (tmp cleaner, disk work, manual cleanup), cleanupWorkspace() first saves a last checkpoint. The checkpoint export returned 404/missing; the existing degradation only covered idle SOP statuses (failed/waiting), so terminal runs treated it as a permanent failure: WorkspaceCleanedAt was never written, the admission slot stayed held, and the sweep retried every 20 seconds forever.

The runner also mapped os.ErrNotExist to HTTP 404 without a semantic error code, so the platform could not distinguish "already gone" from other failures.

Change

  • internal/engine/workspace_checkpoint_stream.go — extend the missing-workspace checkpoint degradation from idleSOPStatus(run) to also include terminal succeeded/cancelled, keeping the runner probe and checkpoint_status double-confirmation. Real RPC errors and offline runners still report normally.
  • internal/runner/workspace.go — fill Code: domain.WorkspaceErrorMissing on ErrNotExist.
  • Tests: terminal run with missing workspace is marked reclaimed (WorkspaceCleanedAt set, admission released, cleanup task enqueued); real transport failure still reported; runner's missing-root response carries the semantic code.

Verification (Linux/amd64, Docker python:3.12)

  • 3 targeted tests RED→GREEN.
  • Directed runner/engine regressions: PASS.
  • go vet, git diff --check: clean. Full package suites are blocked by pre-existing container limits (no bwrap; Chromium unavailable), unrelated to this change.

Scope / notes

A succeeded/cancelled run whose runner workspace is removed from the host
(cleaner, disk work, manual delete) could never finish cleanup: the last
checkpoint export returned 404/missing, the save failed, cleanupWorkspace
returned early, WorkspaceCleanedAt was never written and the admission slot
stayed held — with the sweep retrying every 20s forever (Tencent#1473).

Extend the existing missing-workspace checkpoint degradation from idle SOP
statuses to terminal statuses too, keeping the runner probe and checkpoint
status double-confirmation so real RPC failures/offline runners still report.
Also fill the runner's semantic Code (WorkspaceErrorMissing) on ErrNotExist
so the platform can distinguish 'already gone' from other failures.

Part of Tencent#1473; does not close the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant