Repository navigation
feat: add sandbox expiry #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,6 +254,12 @@ class CreateSandboxRequest(Model): | |
| labels: dict[str, str] = _json( | ||
| "labels", omit_default=True, default_factory=dict | ||
| ) | ||
| timeout_minutes: int = _json( | ||
| "timeout_minutes", omit_default=True, default=0 | ||
| ) | ||
| sigterm_before_expiry: bool = _json( | ||
| "sigterm_before_expiry", omit_default=True, default=False | ||
| ) | ||
|
Comment on lines
+257
to
+262
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Misbound positional sandbox creation arguments Existing positional calls to Learn more
Example: Recommended fix: Move both expiry fields after the existing request fields to preserve the public positional signature. Add a regression test that serializes a request using the old positional arguments. Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| networks: list[NetworkEntry] = _json( | ||
| "networks", omit_default=True, default_factory=list | ||
| ) | ||
|
|
@@ -590,6 +596,8 @@ class CreateSandboxResponse(Model): | |
| bandwidth_quota_bytes: int = 0 | ||
| ingress_url_template: str = "" | ||
| snapshot_id: str | None = None | ||
| expires_at: datetime | None = None | ||
| sigterm_before_expiry: bool = False | ||
|
|
||
|
|
||
| @dataclass(slots=True) | ||
|
|
@@ -621,6 +629,8 @@ class Sandbox(Model): | |
| forked_from: str | None = None | ||
| auto_pause_after_seconds: int | None = None | ||
| snapshot_id: str | None = None | ||
| expires_at: datetime | None = None | ||
| sigterm_before_expiry: bool = False | ||
|
|
||
|
|
||
| @dataclass(slots=True) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,6 +226,8 @@ def handler(request): | |
| "status": "paused", | ||
| "name": "demo", | ||
| "labels": {"team": "backend"}, | ||
| "expires_at": "2026-11-23T12:10:00Z", | ||
| "sigterm_before_expiry": True, | ||
|
Comment on lines
+229
to
+230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "ip": "10.0.0.2", | ||
| "shape": "s-4vcpu-4gb", | ||
| "mem_mib": 4096, | ||
|
|
@@ -244,14 +246,20 @@ def handler(request): | |
| shape="s-4vcpu-4gb", | ||
| name="demo", | ||
| labels={"team": "backend"}, | ||
| timeout_minutes=10, | ||
| sigterm_before_expiry=True, | ||
| ingress_enabled=True, | ||
| ) | ||
| ) | ||
| assert requests[0].url.path == "/api/v1/sandboxes" | ||
| assert json.loads(requests[0].content)["labels"] == {"team": "backend"} | ||
| assert json.loads(requests[0].content)["timeout_minutes"] == 10 | ||
| assert json.loads(requests[0].content)["sigterm_before_expiry"] is True | ||
| assert sandbox.id == "sb-1" | ||
| assert sandbox.status is SandboxStatus.PAUSED | ||
| assert sandbox.data.labels == {"team": "backend"} | ||
| assert sandbox.data.expires_at.isoformat() == "2026-11-23T12:10:00+00:00" | ||
| assert sandbox.data.sigterm_before_expiry is True | ||
| assert sandbox.files and sandbox.processes and sandbox.computer.mouse | ||
| assert sandbox.preview_url(8080) == "https://8080-sb-1.example.test" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Undocumented zero timeout behavior
CreateSandboxRequesthas no docstring explaining that zero omits the timeout rather than sending it for validation. The expiry guide lists only 2–1440 minutes.Was this helpful? React with 👍 or 👎 to provide feedback.