fix(server): make resourceLimits/image/entrypoint optional when poolRef is set#883
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ea9127778
ℹ️ 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".
…ef is set When creating a sandbox from a pre-configured Pool (via extensions.poolRef), the image, entrypoint, and resourceLimits are all defined in the Pool CRD template. Requiring callers to provide dummy values for these fields is unnecessary and error-prone. Changes: - Make resource_limits Optional with None default in CreateSandboxRequest - Skip image/snapshotId/entrypoint validation when poolRef is present - Add explicit resourceLimits required check for non-pool requests - Guard against None resource_limits in Docker provider code paths
9ea9127 to
2abe9a5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2abe9a55ed
ℹ️ 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".
- Skip image/entrypoint resolution in K8s service layer when poolRef is set - Reject poolRef on Docker provider (unsupported) - Reject snapshotId when poolRef is set (conflicting fields) - Update specs/sandbox-lifecycle.yml: remove required constraint on resourceLimits, document pool mode behavior - All 1038 tests pass
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c34c0154a3
ℹ️ 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".
…docs - Fix AttributeError when image is None in pool mode (P1) - Clarify in spec that snapshotId is rejected (not optional) with poolRef
|
Thanks for your submission, this is a very valuable fix. I'll review and merge it as soon as possible. 😊 |
|
Zero new tests for the changed validation paths. The PR modifies 5 files and relaxes a required-field constraint, but no test exercises the new behavior. 1038 existing tests pass, but they only cover the old behavior (everything required). Specific missing coverage:
|
…n, Docker guard, and image auth - Schema: poolRef-only happy path, poolRef+snapshotId rejection, resourceLimits still required without poolRef, blank poolRef ignored - Docker: rejects poolRef with SANDBOX::UNSUPPORTED_POOL_REF - K8s: pool mode skips image/entrypoint validation, image auth guard handles None image without AttributeError All 1046 tests pass (8 new).
|
Thanks for the detailed review @Pangjiping! I just pushed a commit (
Also added a few extra edge cases (blank poolRef ignored, poolRef with optional env/metadata, K8s service-level pool mode skip). All 1046 tests pass now (8 new ones). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c1356b3b2
ℹ️ 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".
When poolRef is set and snapshotId is whitespace-only (e.g. ' '), the validator now clears it to None before returning. This prevents downstream code from treating a truthy whitespace string as a real snapshot ID (e.g. writing an invalid Kubernetes label). Adds test_pool_mode_normalizes_blank_snapshot_id to cover this edge case.
Summary
When creating a sandbox from a pre-configured Pool (via
extensions.poolRef), theimage,entrypoint, andresourceLimitsare all defined in the Pool CRD template. Currently the API requires callers to provide dummy values for these fields, which is unnecessary and error-prone.Fixes #885
Changes
schema.py: Makeresource_limitsOptional[ResourceLimits]withNonedefault; skipimage/snapshotId/entrypointvalidation whenpoolRefis present; rejectsnapshotId+poolRefcombination; add explicitresourceLimitsrequired check for non-pool requestskubernetes_service.py: Skipresolve_sandbox_image_from_requestandensure_entrypointwhenpoolRefis set; guard_ensure_image_auth_supportagainstNoneimagedocker_service.py: RejectpoolRefon Docker provider (unsupported); guard againstNoneresource_limitscontainer_ops.py: Guard againstNoneresource_limitsspecs/sandbox-lifecycle.yml: Removerequired: [resourceLimits], document pool mode behavior, clarifysnapshotIdis rejected withpoolRefBefore (422 error)
After
Testing
uv run pytest tests/ -x -q)