Skip to content

πŸ› Sessions: delete runs in the background with visible progress, and can no longer leave a session listed whose files are gone - #18770

Merged
kubestellar-prow[bot] merged 1 commit into
v5from
fix/session-delete-silent-noop
Nov 17, 2026
Merged

kubestellar-prow[bot] merged 1 commit into
v5from
fix/session-delete-silent-noop

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #18767

What was wrong

Deleting an ended session from the Sessions section looked like it did nothing. The request stayed open for about a minute with no indicator, the dashboard then said "could not remove the session's files" although the files had been removed, and the session stayed listed.

The code path:

  1. handleSessionDelete called UserSessionRuntime.Remove inside the request.
  2. Remove deleted the sandbox with privRun, which is bound to the 10-second userSessionCmdTimeout that exists for tmux calls. A HOME with a CLI's caches takes longer.
  3. When the timeout fired, the cancel of the root child ran su-exec root kill -KILL -- -<pgid>. kill is a shell builtin and the image has no kill binary, so the cancel failed ("su-exec: kill: No such file or directory"). Go then waited for rm to finish by itself and returned the cancel's error.
  4. The handler treated that as a failed removal, answered 500 and kept the record. Files gone, record kept.
  5. Nothing stopped two removals of one session from running at once.

The pre-delete login check from #18728 was not the cause: it runs before anything is removed and returns success when there is nothing to adopt.

What changed

  • Background job. DELETE /api/sessions/{id} on an ended or failed session answers 202 at once; the record is deleting. One job per session id removes the files and then the record, last. A second request, a list or a sweep never starts a second removal.
  • Robust removal. Its own 15-minute ceiling instead of the tmux timeout. What is on disk decides: an error from a command that left nothing behind is success.
  • Cancel that works. The cancel of a privileged child uses the shell's builtin kill (sh -c 'kill -s KILL -- -$1 ...'). That was the only user of the broken helper.
  • Failure is visible. The record goes back to the status it had, with the reason in delete_error. Only a real failure to adopt a strictly newer, usable login blocks a delete on the login side, and it says so: "this session holds the hive's current sign-in; adopting it failed: ...". Nothing is removed in that case.
  • Repair. A deleting record with no job (hive restarted mid-delete) gets its job restarted. An ended record whose sandbox and worktree are both gone is dropped by the reconciler (boot sweep and every list), and a delete click on one completes at once with 200 removed: true.
  • UI. The tab shows "Deleting…" with a spinner and no controls, the list is polled faster through the existing dashboardSetInterval poll while a session is deleting, the tab disappears when the record is gone, and a failure brings it back with the reason, a toast and a Retry delete button. Closing a running session no longer drops the tab locally only for the next poll to bring it back.
  • Log and audit. One log line with the duration and one session_closed audit entry per outcome, failures included.
  • DELETE ...?remove=true on a running session closes and deletes it. A record a restart left preparing can be deleted.

The start path already shows progress (preparing with a spinner and the server's message), so it is unchanged.

Notes for review

Tests

  • Runtime: expired login copy, no login file, refresh-less copy and a non-credential file each delete; adoption failure removes nothing and names the reason; command error with the directory gone is success, with it left is a failure that a retry completes; the sandbox removal's deadline; Removed; the kill script ends a real process group with an empty PATH.
  • Dashboard: the delete outlives the request and runs once; failure keeps the session with the reason and restores the previous status; error with files gone is success; a stale record is repaired by a click and by the reconciler; an interrupted delete is finished; every state; the role matrix.
  • JS: the deleting state, the tab removed on success, a toast with the reason on failure, Retry delete.

Synthetic credentials only.

πŸ€– Generated with Claude Code

…r leaves a record whose files are gone

Deleting an ended session ran inside the request under the 10-second tmux
command timeout. A sandbox with a CLI's caches outlasts it; the cancel ran
'su-exec root kill', which cannot work (the image has no kill binary), so rm
finished by itself and the cancel's error was reported over a removal that
had succeeded. The files were gone, the record was kept, and the dashboard
said the files could not be removed, a minute later.

- DELETE on an ended or failed session answers 202; the record is 'deleting'
  and one job per session id removes the files, then the record, last
- removal has its own 15-minute ceiling; what is on disk decides the outcome
- the cancel of a root child uses the shell's builtin kill
- a failure puts the record back with delete_error; the UI shows it and
  offers Retry delete
- the reconciler restarts an interrupted delete and drops an ended record
  whose sandbox and worktree are both gone
- only a real failure to adopt a strictly newer usable login blocks a delete,
  with a clear reason; nothing to adopt is success
- one log line with the duration and one session_closed audit per outcome

Fixes #18767

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#18771 ✨ Customers: a read-only GraphQL endpoint over the customer graph same files dashboard/openapi.json
src/pkg/dashboard/static/index.html
#18772 πŸ› Activity monitor: one rule for the human-gate pill and its verbs; name the real blocker same files src/pkg/dashboard/static/index.html

@clubanderson clubanderson added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 17, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow
kubestellar-prow Bot merged commit bec8e37 into v5 Nov 17, 2026
110 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/session-delete-silent-noop branch November 17, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

πŸ› Sessions: deleting a session is slow, silent, and can leave a record whose files are gone

1 participant