refactor(server): make snapshot create path synchronous for k8s/fsb runtimes - #2098
Open
Pangjiping wants to merge 1 commit into
Open
Pangjiping wants to merge 1 commit into
Pangjiping wants to merge 1 commit into
Conversation
…untimes Root fix for the early-read Failed race (opensandbox-group#2092, follow-up to opensandbox-group#2077). k8s and fsb create_snapshot are fast, idempotent submits (CR name / fsb request_id derive from the snapshot id), so POST /snapshots now creates the runtime object before persisting the Creating row and returns without touching the worker pool. Once a row is readable, the runtime object always exists, so read-time sync and recovery can never map a not-yet-created object to Failed, including on other HA replicas. A persist failure after runtime creation triggers best-effort deletion of the runtime object. Recovery retries stuck k8s/fsb rows inline instead of resubmitting workers, keeping the pool and the in-flight guard docker-only. Docker (slow container.commit) keeps the existing async create path unchanged.
Pangjiping
requested review from
Generalwin,
hittyt,
jwx0925 and
ninan-nn
as code owners
September 30, 2026 14:11
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Failedrace (refactor(server): make snapshot create path synchronous for k8s/fsb runtimes (root fix for early-read Failed) #2092, follow-up to fix(server): don't fail a snapshot that is read before its worker runs #2077): for k8s/fsb,POST /sandboxes/{id}/snapshotsnow creates the runtime object (SandboxSnapshot CR / fsb submit) before persisting theCreatingrow and returns without touching the worker pool. Both submits are fast and idempotent (CR name / fsbrequest_idderive from the snapshot id), so once a row is readable the runtime object always exists — read-time sync and recovery can no longer map a not-yet-created object toFailed, including on other HA replicas._worker_in_flightguard docker-only (the read-path guard is removed; it was unreachable for docker rows, which have no change stream).500 SNAPSHOT::RUNTIME_CREATE_FAILEDwith no row persisted.container.commit()is genuinely slow).docs/architecture/fast-sandbox/checkpoints.md.Closes #2092
Testing
Not run (explain why)
Unit tests
Integration tests
e2e / manual verification
uv run ruff checkclean;uv run pytestfull suite: 2173 passed (withOPENSANDBOX_TEST_POSTGRESQL_DSN, includes the 3 HA PostgreSQL integration tests; pyright has no new findings vs main).New/updated tests cover the acceptance criteria from refactor(server): make snapshot create path synchronous for k8s/fsb runtimes (root fix for early-read Failed) #2092:
Creating(test_synchronous_create_submits_runtime_before_persisting)SNAPSHOT::RUNTIME_CREATE_FAILED, nothing persisted (test_synchronous_create_failure_returns_error_without_persisting)test_synchronous_create_cleans_up_runtime_object_when_persist_fails)test_recovery_retries_synchronous_create_inline_without_worker)Failed(unit:test_ha_recovery_converges_fsb_snapshot_without_failed_mapping; integration:test_fsb_snapshot_row_is_recovered_by_peer_replica)Breaking Changes
Behavior note (not a contract change): for k8s/fsb, a runtime submit failure now surfaces as a synchronous 500 on POST instead of eventually transitioning an accepted row to
Failed. The 202 +Creating+ poll contract is unchanged.Checklist