Skip to content

fix(provisioner): keep a held seed bundle until its resend arrives - #618

Merged
moonlight16 merged 2 commits into
rossoctl:mainfrom
moonlight16:fix/seed-reserve-replacement
Oct 27, 2026
Merged

moonlight16 merged 2 commits into
rossoctl:mainfrom
moonlight16:fix/seed-reserve-replacement

Conversation

@moonlight16

Copy link
Copy Markdown
Member

Follow-up to Paolo's review of #600 (a PVC per workload).

Background

  1. When a workload with a PVC is activated, the worker sends the workload's tar file to the provisioner.
  2. The provisioner holds it in memory until pod 0 downloads it and extracts it onto the PVC.
  3. If the activate is retried before then, the worker sends the tar file again: a resend.

Today

  1. As soon as a resend starts, the provisioner drops the copy it holds. If the resend then fails or is refused, both are gone, and pod 0 can't fill the PVC until the user activates again (seed_bundle_missing).
  2. If pod 0 is still downloading the old copy when a resend arrives, both copies are in memory, but the budget check counts only one. Real memory can then exceed the budget.

With this PR

  1. The old copy stays held, and still downloadable, until the new one has fully arrived and been accepted. Then they swap. A failed or refused resend leaves the old copy as it was.
  2. The global and per-owner budget checks count every copy actually in memory, so the budget always holds.

Behavior change: during a resend, both copies count against the owner's half of the budget until they swap. A large tar file, over about 256 MiB at the defaults, can't be resent while its first copy is still held. It goes through once that copy is seeded or expires.

Tested:

  • typecheck is clean, and all 73 provisioner tests pass;
  • 4 new tests fail on the old code: a resend that fails mid-upload, a refused resend, a resend while pod 0 is still downloading, and the per-owner share;
  • Prettier passes.

🤖 Generated with Claude Code

Follow-up to rossoctl#600 review. reserve() no longer drops the held bundle; the old
one stays fetchable until the replacement has fully arrived and put() accepts
it, so a failed or refused resend keeps it. The global and per-owner checks
count the held bundle and every lingering buffer still being served, so
in-process bundle memory never exceeds the budget.

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 26, 2026 18:59
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 26, 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

A resend now keeps the held bundle until the new one is fully read and accepted (put), and bundles that are dropped but still being sent (lingering) now count against their owner's share. Both close real gaps: losing both copies on a failed resend, and memory going over the per-owner share during a GET. I traced the logic. reserve counts held + reserved + lingering. put drops the old copy, which moves it to lingering if a GET is serving it. The release in server.ts finally runs after put, so the bytes are never counted twice or missed. Every refusal path (retired, kube error, already seeded) leaves the old copy untouched. The new tests cover each case. One suggestion about documenting the stricter resend headroom.

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

if (replaced) this.drop(wl);
reserve(own: string, n: number): boolean {
if (this.inMemory + n > this.budget) return false;
if (this.ownerBytes(own) + n > this.ownerBudget) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Behaviour change worth surfacing in docs: with the defaults (budget 1 GiB → owner share 512 MiB, MOCA_CONTEXT_BUNDLE_MAX_BYTES 256 MiB), an owner holding one max-size bundle can resend it only if nothing else of theirs is held, and a resend of a bundle while a seed GET is still sending the previous replacement can need 3× its size. main.ts:72 still enforces only budget >= 2 × max, which now means "a max-size bundle can be resent only when the owner holds nothing else". Consider noting in docs/reference/configuration.md (the MOCA_PROVISIONER_SEED_BUDGET_BYTES row) and spec §5.2 that a resend counts alongside the copy it replaces, so operators who raise MOCA_CONTEXT_BUNDLE_MAX_BYTES know to size the budget at ≥4× for resends to go through. The worker passes 503 + Retry-After through, so the failure mode is correct; this is only about predictability.

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.

Agreed, documented in 07e7ad6: spec §5.2 now says a resend counts alongside the copy it replaces, and a copy still being sent counts until its GET ends, so a resend can need up to 3× the bundle; with the defaults a 256 MiB bundle can be resent only while its owner holds nothing else. The MOCA_PROVISIONER_SEED_BUDGET_BYTES row in configuration.md says to size the budget at 4× MOCA_CONTEXT_BUNDLE_MAX_BYTES or more for resends to go through.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Jeremy Cohn <[email protected]>
@moonlight16
moonlight16 merged commit e0d43c4 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.

3 participants