Skip to content

feat(provisioner): report PVCs the sweep kept on missing records - #643

Merged
moonlight16 merged 2 commits into
rossoctl:mainfrom
moonlight16:feat/sweep-report-kept-pvcs
Oct 27, 2026
Merged

moonlight16 merged 2 commits into
rossoctl:mainfrom
moonlight16:feat/sweep-report-kept-pvcs

Conversation

@moonlight16

Copy link
Copy Markdown
Member

Follow-up to Paolo's review of #615 (the cleanup sweep). Closes #625.

Today

  1. When a workload's record is missing from Redis, the cleanup sweep deletes its sandbox pods but keeps its PVC. A wrong or emptied Redis must never delete someone's data.
  2. Nothing removes those PVCs afterwards. They count against the moca-sandbox quota (32 PVCs and 320Gi by default), and the only sign is a per-workload log line that's easy to miss. Once enough pile up, new workloads with storage fail to get a PVC, with no obvious reason why.

With this PR

  1. The sweep's result gains a kept count: PVCs kept in this pass, plus ones kept earlier that are still there.
  2. While any are kept, every pass logs one summary line: N PVC(s) kept on missing records; they count against the moca-sandbox ResourceQuota until deleted by hand.
  3. docs/context-service.md explains that kept PVCs count against the quota, with commands to list them and to delete one. Nothing is deleted automatically: that stays a human decision.

Tested: typecheck is clean, and all 111 provisioner tests pass. A new test checks the summary appears on every pass and stops once the PVC is gone. The existing tests now check the exact kept count.

🤖 Generated with Claude Code

Closes rossoctl#625. SweepResult gains kept (this pass's and earlier lone claims),
orphanSweeper logs a summary every pass while any are kept, and
docs/context-service.md says they count against moca-sandbox's
ResourceQuota, with commands to list and remove them.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Jeremy Cohn <[email protected]>
@moonlight16
moonlight16 requested a review from pdettori as a code owner October 27, 2026 19:14
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 27, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Looks good. kept counts both paths correctly: the lone claim kept on an earlier pass (now kept, not skipped, and still excluded from the emptied-Redis guard), and the claim kept in this pass's sweepDue, counted only when the PVC was actually there. The summary line repeats every pass, and the new test pins that it stops once the record says deleted. The quota figures in the docs match provisioner.yaml, and SweepResult has no other consumers. One docs nit inline.

Author: moonlight16 (MEMBER — maintainer)
Areas reviewed: TypeScript (provisioner), tests, docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing

Comment thread docs/context-service.md Outdated
known to be unwanted:

```bash
kubectl -n moca-sandbox get pvc -l app=moca-workload-sandbox -L moca.dev/workload

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: this lists every workload PVC, live ones included, so the reader still has to cross-check them against StatefulSets by hand (the note under the block says so). Consider printing the kept ones directly, e.g.:

comm -23 <(kubectl -n moca-sandbox get pvc -l app=moca-workload-sandbox -o name | sed 's|.*/||' | sort) \
         <(kubectl -n moca-sandbox get sts -l app=moca-workload-sandbox -o name | sed 's|.*/||' | sort)

(A claim still inside its grace window, between its create and its StatefulSet's, can show up briefly too. Re-run before deleting anything.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good idea, done in a02b33c: the block now uses your comm -23 to print only the kept PVCs, and says to run it again before deleting, since a workload still being created can show up briefly.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Jeremy Cohn <[email protected]>
@moonlight16
moonlight16 merged commit 27488f5 into rossoctl:main Oct 27, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Orphan sweep: report and document PVCs kept on missing records

3 participants