feat(sdks): client sandbox pool implementation#393
feat(sdks): client sandbox pool implementation#393ninan-nn wants to merge 1 commit intoalibaba:mainfrom
Conversation
543d870 to
991e526
Compare
991e526 to
9ecdc1f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ecdc1f260
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/pool/SandboxPool.kt
Show resolved
Hide resolved
...andbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/pool/PoolReconciler.kt
Outdated
Show resolved
Hide resolved
...box/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/domain/pool/PoolConfig.kt
Outdated
Show resolved
Hide resolved
9ecdc1f to
75ca5a8
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75ca5a84db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/pool/SandboxPool.kt
Outdated
Show resolved
Hide resolved
3495072 to
c7519f5
Compare
c7519f5 to
9c776ed
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c776ed674
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| private fun directCreate(sandboxTimeout: Duration?): Sandbox { | ||
| val sandbox = buildSandboxFromSpec() | ||
| sandboxTimeout?.let { sandbox.renew(it) } |
There was a problem hiding this comment.
Clean up direct-created sandbox when renew fails
If sandboxTimeout is set and sandbox.renew(...) throws (for example on transient API/network errors), directCreate exits by exception without killing or closing the newly created sandbox. Because the caller never receives the Sandbox handle, that instance is orphaned and can keep running until the default 24h TTL, consuming remote capacity and local client resources. Add a failure cleanup path (kill/close best-effort) before rethrowing.
Useful? React with 👍 / 👎.
| .sandboxId(sandboxId) | ||
| .connectionConfig(connectionConfig) | ||
| .connect() | ||
| sandboxTimeout?.let { sandbox.renew(it) } |
There was a problem hiding this comment.
Close connected sandbox on idle renew failure
The idle acquire path performs connect() and then renew() in one try block; when renew() fails after a successful connect, execution jumps to the catch block and the connected Sandbox object is discarded without close(). Although the code attempts remote kill, the local HTTP client/provider resources for that connected handle are leaked in this failure path, which can accumulate under intermittent renew failures.
Useful? React with 👍 / 👎.
Summary
SandboxPoolwith client-side idle buffer management and configurable acquire policy (FAIL_FAST/DIRECT_CREATE).PoolConfig,PoolCreationSpec,PoolSnapshot,PoolState,PoolStateStore, andInMemoryPoolStateStore.putIdleSandboxPool:resizevsshutdownrace handling (RejectedExecutionExceptionsafe path)drainTimeout)@Deprecatedannotation fromSandboxPoolto align with README guidance while keeping feature marked experimental in docs.Testing
Executed:
cd sdks/sandbox/kotlin && ./gradlew spotlessApply buildcd tests/java && ./gradlew test --tests "*SandboxPool*E2ETest"Result summary:
SandboxPoolSingleNodeE2ETest: 15/15 passedSandboxPoolPseudoDistributedE2ETest: 7/7 passedBreaking Changes
Checklist