Repository navigation
Conversation
Ask GetSandbox for the owner replica, cache it for 30 seconds, and send it as x-openshell-replica on ExecSandbox. Retry once without the hint when the per-replica route has no healthy endpoint, forgetting the cached owner. Part of NVIDIA#4223 Signed-off-by: divesh <dgude@nvidia.com>
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
The Python SDK now sends exec calls straight to the gateway replica that owns the sandbox's supervisor session, as the CLI already does. Behind an edge proxy with replica routing enabled, this skips the relay hop through a peer replica; without one, the header is ignored and behavior is unchanged.
Related Issue
Part of #4223 (the "Every SDK asks for the owner and sends the replica hint, like the CLI" item, Python portion). Rust is #4790, Go is #4852, TypeScript is #4877.
Changes
exec_stream(and soexec,exec_python, and the session helpers) looks up the owner withGetSandboxand caches it per workspace and sandbox for 30 seconds, like the Rust SDK. A failed lookup leaves the call unrouted.ExecSandboxcarriesx-openshell-replicaand retries once without it when Envoy reports the owner's route has no ready endpoints (same rule as the CLI), forgetting the cached owner.Release Notes
Python SDK exec calls now take the direct route to the sandbox's owner replica when replica routing is enabled.
Testing
mise run python:lint,python:format:check,python:typecheck,test:python)GetSandbox(unhinted baseline split 5/5), still succeeded via unrouted retry and peer relay when the owner's route had no endpoints, and followed the owner to the other replica after a gateway restart.Checklist