Skip to content

pool: a resize is refused on a fenced node when its target pool replicates; a volume change that meets a resize answers 503 - #676

Merged
CMGS merged 3 commits into
mainfrom
pool-resize-volume-fence
Nov 30, 2026
Merged

CMGS merged 3 commits into
mainfrom
pool-resize-volume-fence

Conversation

@CMGS

@CMGS CMGS commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What

Two small fixes for POST /v1/sandboxes/{id}/resize, both found while the pool was read end to end for the checklist in #675.

  1. A resize into a pool that replicates is refused while the node's lease is overdue. The swap refused a fenced node only for a claim that was already replicated. A claim of a pool that does not replicate, resized into one that does, was published as replicated on the fenced node: the resize answered 204, and every call to the claim then answered 503 lease lost; retry until the fence lifted. A new claim of that pool is refused in the same state. The check now also covers the pool the claim's policy would follow (its PolicySource when set, else the target key). It runs before the cocoon call, where a refusal changes nothing, and again at the swap.
  2. A volume PUT or PATCH that meets a resize answers 503, not 404. A volume change begins on the record it looked up and then resolves its volumes. When a resize replaced the record meanwhile, the change answered 404 for a claim that still exists. It now answers 503 sandbox changed while the call waited; retry, as the other calls do; a released claim still answers 404.

Reach

  • (1) needs two pools of one template and lane with different replicate_seconds, and a lease that is overdue during the call. It heals itself when the lease returns, and no peer can adopt the claim meanwhile, since it has no replica yet.
  • (2) needs a volume change sent to a hibernated claim (which otherwise answers 409) whose volume lookup straddles the swap.

Tests

  • TestAResizeIntoAReplicatingPoolIsRefusedWhileTheNodeIsFenced: the lease overdue at the start (cocoon is not called); the lease lost while cocoon resizes the VM; a promoted template's clone, whose policy key does not replicate, is not refused.
  • TestAVolumeChangeThatMeetsAResizeAnswersTheRetry: a run begun before the resize, and one begun on the replaced record.
  • Five mutants (the swap checking only the source; no check at the start; the target key in place of the policy key; each of the two volume checks back to 404) each fail a test. Both tests pass 20 times under -race.
  • Local gate: lint 0 issues. for the five modules on darwin and linux, asl, fmt, comments +0 −0, darwin and linux race tests green.

Hot path

None. The resize check is on an operator call; the volume checks swap one map compare for another under a mutex they already hold.

Merge order

Merge this before #675: the checklist there is updated to describe these two rows as handled.

CMGS added 2 commits November 30, 2026 22:11
…cates; a volume change that meets a resize answers 503

reshape refused a resize on a fenced node only for a claim that was already
replicated. A claim of a pool that does not replicate, resized into one that
does, was published Replicated on the fenced node: the resize answered 204
and every call to the claim then answered "lease lost" until the fence
lifted, where a new claim of that pool is refused. fencedFor now also asks
fencedReplicating for the key the claim's policy would have (PolicySource
when set, else the target key). Resize asks it before the cocoon call, so
the refusal changes nothing, and reshape asks it again at the swap.

A volume PUT or PATCH begins its run on the record it looked up, then
resolves its volumes. When a resize replaced the record meanwhile,
checkVolumeRunLocked and beginVolumeRun answered ErrUnknownSandbox (404) for
a claim that still exists. They now answer through heldErrLocked: ErrReplaced
(503, retry) when another record holds the id.

Tests: a resize into a replicating pool is refused when the lease is overdue
at the start (cocoon is not called) and when it is lost while cocoon resizes
the VM; a promoted template's clone, whose policy key does not replicate,
is not refused. A volume run begun before a resize, and one begun on the
replaced record, answer ErrReplaced.
@CMGS
CMGS merged commit 35a1db1 into main Nov 30, 2026
2 checks passed
CMGS added a commit that referenced this pull request Dec 1, 2026
…e refuses a resize into a replicating pool (#684)

Docs for behaviour that PRs merged since v0.1.38 changed: egress.md states that an origin's early answer or the proxy's own 502 or 429, sent before the guest's request body was read to its end, carries Connection: close, arrives whole, and ends that guest connection (#681); cluster.md states the resize refusal on a node whose lease is overdue and that a claim resized into its policy pool is replicated from then on (#676), and that the hourly row settling leaves a claim a transition holds to the next pass (#674); CHECKLIST.md states the archive sweep worker's check before it marks a claim (#679); deploy.md states that a preview URL can show a truncated reply when the guest app answers before it read the whole request body.
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