Skip to content

fix: reserve sandbox IDs until node cleanup completes - #445

Open
Floating-Y wants to merge 2 commits into
deeplethe:devfrom
Floating-Y:fix/id-reuse-cleanup
Open

Floating-Y wants to merge 2 commits into
deeplethe:devfrom
Floating-Y:fix/id-reuse-cleanup

Conversation

@Floating-Y

Copy link
Copy Markdown
Collaborator

Deleting demo and immediately recreating it previously returned 201 with a new token while the old instance was still running. A subsequent node report could make the master dispatch the replacement's Exec to that old instance, even when the template changed.

Persist a SQLite cleanup reservation for the ID, original node and creation token, network slot and gateway port. Explicit ID reuse now returns 409 with a cleanup reason and no token until the owning node acknowledges successful removal of that exact instance. Sending Destroy, receiving a command or reporting an empty observation does not release the reservation.

Bind sandbox commands, queued Exec and reported failures to the creation token. Nodes check tokens under the shared sandbox lock and persist retirement markers so delayed Exec, Destroy or Create commands cannot affect a replacement. Cleanup confirms that the cgroup is empty and local instance resources have been removed; failures remain retryable. Reservations and acknowledgement retries survive master/node restarts and disconnects.

DELETE continues to return 204 and removes the API view immediately. After cleanup, the ID can be recreated with a fresh token; the old token is refused and unrelated IDs remain usable.

Compatibility: upgrade the master before its nodes. Older nodes cannot acknowledge cleanup, so their reservations remain until those nodes are upgraded and report completion. New nodes reject unscoped commands against token-protected instances.

Validation

  • Reproduced on upstream dev at d27ab7c: both same-template and different-template regression cases failed before the fix, with 201 and actual Exec delivery to the old instance.
  • Added six deterministic master_api regressions without timing sleeps, covering cleanup acknowledgements, ID reuse, old/new tokens, restart/disconnect recovery, queued Exec and stale reports. Tests inspect the commands the node receives.
  • Added node/store checks for command isolation, persistent retirement and acknowledgement retries, failed cleanup, stable per-ID locks and atomic token publication.
  • cargo test --all --quiet: 423 tests passed, including all 74 master_api tests.
  • cargo fmt --all -- --check: passed.
  • cargo clippy --all-targets --all-features --quiet -- -D warnings: passed.
  • cargo build --all --quiet: passed.

Real runsc/Firecracker integration and performance benchmarks were not run.

Signed-off-by: danwood <118035379+Floating-Y@users.noreply.github.com>
Signed-off-by: danwood <118035379+Floating-Y@users.noreply.github.com>

This branch has not been deployed

No deployments
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