Repository navigation
feat: add sandbox expiry #6
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,9 @@ public record CreateSandboxRequest( | |
| String region, | ||
| @JsonProperty("auto_pause_after_seconds") Integer autoPauseAfterSeconds, | ||
| Map<String, String> labels, | ||
| @JsonProperty("snapshot_id") String snapshotId) { | ||
| @JsonProperty("snapshot_id") String snapshotId, | ||
| @JsonProperty("timeout_minutes") Integer timeoutMinutes, | ||
| @JsonProperty("sigterm_before_expiry") Boolean sigtermBeforeExpiry) { | ||
| /** Validates required values and defensively copies collection values. */ | ||
| public CreateSandboxRequest { | ||
| if ((shape == null || shape.isBlank()) && (snapshotId == null || snapshotId.isBlank())) { | ||
|
|
@@ -71,6 +73,8 @@ public CreateSandboxRequest( | |
| region, | ||
| autoPauseAfterSeconds, | ||
| Map.of(), | ||
| null, | ||
| null, | ||
| null); | ||
| } | ||
|
|
||
|
|
@@ -107,6 +111,8 @@ public CreateSandboxRequest( | |
| region, | ||
| autoPauseAfterSeconds, | ||
| labels, | ||
| null, | ||
| null, | ||
| null); | ||
| } | ||
|
|
||
|
|
@@ -138,6 +144,8 @@ public static final class Builder { | |
| private Integer autoPauseAfterSeconds; | ||
| private Map<String, String> labels = Map.of(); | ||
| private String snapshotId; | ||
| private Integer timeoutMinutes; | ||
| private Boolean sigtermBeforeExpiry; | ||
|
|
||
| private Builder(String shape) { | ||
| this.shape = shape; | ||
|
|
@@ -161,6 +169,18 @@ public Builder labels(Map<String, String> labels) { | |
| return this; | ||
| } | ||
|
|
||
| /** Sets the absolute lifetime in whole minutes (2-1440) from first reaching running. */ | ||
| public Builder timeoutMinutes(int timeoutMinutes) { | ||
| this.timeoutMinutes = timeoutMinutes; | ||
| return this; | ||
| } | ||
|
|
||
| /** Requests a best-effort SIGTERM warning in the final minute. Requires a timeout. */ | ||
| public Builder sigtermBeforeExpiry(boolean sigtermBeforeExpiry) { | ||
| this.sigtermBeforeExpiry = sigtermBeforeExpiry; | ||
| return this; | ||
| } | ||
|
|
||
| /** Restores an owned ready reusable snapshot instead of a root filesystem. */ | ||
| public Builder snapshotId(String snapshotId) { | ||
| this.snapshotId = snapshotId; | ||
|
|
@@ -251,7 +271,9 @@ public CreateSandboxRequest build() { | |
| region, | ||
| autoPauseAfterSeconds, | ||
| labels, | ||
| snapshotId); | ||
| snapshotId, | ||
| timeoutMinutes, | ||
| sigtermBeforeExpiry); | ||
|
Comment on lines
+274
to
+276
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. |
||
| } | ||
| } | ||
| } | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,7 @@ void createsSandboxWithExpectedWireNames() { | |
| exchange, | ||
| 200, | ||
| """ | ||
| {"status":"success","data":{"id":"sb-1","status":"running","labels":{"team":"backend"},"ip":"10.0.0.2","shape":"s-4vcpu-4gb","rootfs":"devbox:1","vcpu":4,"mem_mib":4096,"disk_mib":8192,"spawn_ms":42.5,"egress":[],"ingress_url_template":"https://<port>.example.test"}} | ||
| {"status":"success","data":{"id":"sb-1","status":"running","labels":{"team":"backend"},"expires_at":"2026-11-23T12:10:00Z","sigterm_before_expiry":true,"ip":"10.0.0.2","shape":"s-4vcpu-4gb","rootfs":"devbox:1","vcpu":4,"mem_mib":4096,"disk_mib":8192,"spawn_ms":42.5,"egress":[],"ingress_url_template":"https://<port>.example.test"}} | ||
| """); | ||
| }); | ||
|
|
||
|
|
@@ -100,6 +100,8 @@ void createsSandboxWithExpectedWireNames() { | |
| CreateSandboxRequest.builder("s-4vcpu-4gb") | ||
| .rootFileSystem("devbox:1") | ||
| .labels(Map.of("team", "backend")) | ||
| .timeoutMinutes(10) | ||
| .sigtermBeforeExpiry(true) | ||
| .ingressEnabled(true) | ||
| .build()); | ||
|
|
||
|
|
@@ -108,7 +110,11 @@ void createsSandboxWithExpectedWireNames() { | |
| assertTrue(requestBody.get().contains("\"rootfs\":\"devbox:1\"")); | ||
| assertTrue(requestBody.get().contains("\"ingress_enabled\":true")); | ||
| assertTrue(requestBody.get().contains("\"labels\":{\"team\":\"backend\"}")); | ||
| assertTrue(requestBody.get().contains("\"timeout_minutes\":10")); | ||
| assertTrue(requestBody.get().contains("\"sigterm_before_expiry\":true")); | ||
| assertEquals(Map.of("team", "backend"), sandbox.labels()); | ||
| assertEquals(java.time.Instant.parse("2026-11-23T12:10:00Z"), sandbox.data().expiresAt()); | ||
| assertTrue(sandbox.data().sigtermBeforeExpiry()); | ||
|
Comment on lines
+116
to
+117
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. |
||
| assertFalse(requestBody.get().contains("disk_mib")); | ||
| } | ||
|
|
||
|
|
||
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.
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.
📝 Info: Snapshot constructor compatibility gap
The expiry components replace the snapshot-aware constructors on
CreateSandboxRequest,CreateSandboxResponse, andSandboxData. Only the older overloads remain.Was this helpful? React with 👍 or 👎 to provide feedback.