Skip to content

atelet: detached actors no longer pin sandbox assets in the node cache - #2772

Closed
Eric Curtin (ericcurtin) wants to merge 2 commits into
agent-substrate:mainfrom
ericcurtin:detach-remove-sandbox-assets
Closed

Eric Curtin (ericcurtin) wants to merge 2 commits into
agent-substrate:mainfrom
ericcurtin:detach-remove-sandbox-assets

Conversation

@ericcurtin

Copy link
Copy Markdown
Contributor

Detach now deletes the actor's sandbox asset hard links, so the asset cache can evict them.

Fixes #2742

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Dmitry Berkovich (@dberkov) ILLUM1N0X PTAL when you get a chance. Thank you!

q-qp-p pushed a commit to q-qp-p/substrate that referenced this pull request Oct 19, 2026
atelet's `DetachActor` returned UNIMPLEMENTED. Without it,
ate-api-server can't make a suspended actor's latest snapshot durable
and free it from the node on demand. Resuming the actor on another node
needs that.

The handler validates the request and runs the snapshot tracker's
`Detach`. That's the same detach atelet runs on its own after
`--snapshot-detach-delay`. The handler returns the actor's new snapshot
state.

#### API changes

- `Atelet.DetachActor` (atelet internal) is now implemented. The proto
comment drops its "returns UNIMPLEMENTED" TODO. No fields change.

#### Not in this PR

- Detach deletes the actor's local snapshots but not the rest of the
actor's directory. The detach atelet runs on its own does the same.
Removing the whole directory overlaps agent-substrate#2742 and agent-substrate#2772, and belongs in
the tracker so both paths get it.
- Nothing in ate-api-server calls `DetachActor` yet. Resuming elsewhere
will be a follow-up.

@igooch igooch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right. The removal sits after the prune and before LatestLocal is cleared, so a failed removal is retried with the detach, and Run and Restore re-stage the assets for a later resume on the node.

On ordering with #2871, which has detach remove the whole actor directory. I'd land this first. It is small, and it reclaims the only part of a detached actor's leftovers that pins disk. #2871 then drops the removeSandboxAssets call in its rebase and keeps the nlink test from here as a regression check.

This needs a rebase before it can merge. The conflict is one comment block in finishDetach, against the recordDetach hunk from #2815.

@bowei Bowei Du (bowei) added area/node area/storage kind/bug Something isn't working / bugfixes labels Oct 19, 2026
@ericcurtin

Copy link
Copy Markdown
Contributor Author

Merged main; it applies cleanly now, so no conflict is left. igooch thank you for the review.

// call; a worker's detach makes a report of what it changed due, while a
// Detach call returns the new state and cancels any pending report. A detach
// Forget abandons leaves the actor alone, and fails.
// snapshots and sandbox asset links. background reports whether a worker runs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit 🟢 – Other docs still describe a detach as deleting only the local snapshots. docs/sandbox-asset-cache.md says when an actor's links are made and kept, but not that a detach drops them. In docs/metrics/registry/metrics.yaml, the atelet.snapshot.detach.duration note says a failed detach keeps the local snapshots, which no longer holds when only the link removal fails. The Detach doc at line 42 and the Tracker doc in tracker.go could mention the links too.

}
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
t.Skip("link counts are unavailable on this platform")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit 🟢 – This skip is unreachable, since os.Stat returns a *syscall.Stat_t wherever this file compiles. If it ever fired, the test would skip its link-count checks instead of failing. Calling syscall.Stat and failing on error, as allocatedBytes in filecache_test.go does, drops the branch.

@igooch

igooch commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Eric Curtin (@ericcurtin) looks like this PRs functionality mostly merged in #2871. Are you OK with closing this PR?

@ericcurtin

Copy link
Copy Markdown
Contributor Author

igooch thank you, agreed #2871 covers this. I will check what is left and follow up.

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Agreed, #2871 already removes the sandbox asset links on detach, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/node area/storage kind/bug Something isn't working / bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atelet: detach must delete the actor's sandbox-assets hard links so the asset cache can evict them

4 participants