Add scheduled instance snapshots with retention cleanup#139
Add scheduled instance snapshots with retention cleanup#139sjmiller609 wants to merge 20 commits intomainfrom
Conversation
✱ Stainless preview buildsThis PR will update the Edit this comment to update it. It will appear in the SDK's changelogs. ✅ hypeman-typescript studio · code · diff
✅ hypeman-openapi studio · code · diff
✅ hypeman-go studio · code · diff
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
There was a problem hiding this comment.
Stale comment
Automated Risk Assessment
Medium-Highrisk. Review is required, so this PR is not approved by automation.Evidence from the diff:
- Adds a new background scheduler loop in
cmd/api/main.gothat periodically executes snapshot schedule runs.- Introduces substantial new scheduling and retention logic in
lib/instances/snapshot_schedule.go, including automatic snapshot deletion paths.- Expands public API surface with new snapshot-schedule endpoints in
cmd/api/api/snapshots.goandopenapi.yaml(plus regenerated bindings inlib/oapi/oapi.go).- Changes are cross-cutting across API, runtime behavior, persistence, and cleanup semantics, increasing regression and operational blast radius.
Validation notes:
- Attempted targeted tests, but they could not run in this environment due missing embedded binary assets under
lib/vmm,lib/system, andlib/ingress.Action taken:
- Requested reviewers:
rgarcia,hiroTamada.
There was a problem hiding this comment.
Automated Risk Assessment
Medium-High risk. Review is required, so this PR is not approved by automation.
Assessment based on the code diff:
- Adds a new minute-polling background scheduler in
cmd/api/main.gothat executes asynchronous snapshot work continuously. - Introduces substantial new scheduling/retention execution logic in
lib/instances/snapshot_schedule.go, including automatic snapshot deletion paths. - Expands production API surface via new schedule endpoints in
cmd/api/api/snapshots.goand schema/binding changes inopenapi.yamlandlib/oapi/oapi.go. - Persists and loads schedule state on disk (
lib/scheduledsnapshots/storage.go,lib/paths/paths.go), increasing operational/state-management complexity.
Reviewer handling:
- Code review is required for this risk level.
- No additional reviewer requests were made because 2 reviewers are already assigned (
hiroTamada,rgarcia).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


Summary
max_count/max_age)API
GET /instances/{id}/snapshot-schedulePUT /instances/{id}/snapshot-scheduleDELETE /instances/{id}/snapshot-scheduleNotes
Testing
go test ./lib/instances -run SnapshotSchedule -count=1go test ./cmd/api/api -run Snapshot -count=1go test ./cmd/api -run TestOapiRuntimeBindStyledParameter_URLDecoding -count=1Note
Medium Risk
Adds new background scheduling/cleanup logic that creates and deletes snapshots automatically, which could impact data retention and storage if scheduling/retention rules behave unexpectedly.
Overview
Adds per-instance scheduled snapshots via new
GET/PUT/DELETE /instances/{id}/snapshot-scheduleendpoints, including request validation (duration parsing, required retention) and a newSnapshotScheduleAPI model.Implements schedule persistence under a new
snapshot-schedules/data directory and a background scheduler incmd/api/main.gothat polls every minute to run due schedules, auto-select snapshot kind based on instance state, record run status (next_run_at,last_*fields), and apply retention cleanup (max_count/max_age) only to scheduled snapshots.Introduces a small
lib/scheduledsnapshotspackage for schedule validation/naming/storage helpers, addsErrSnapshotScheduleNotFound, updates docs, and regenerates OpenAPI server/client bindings; includes unit tests covering schedule lifecycle, retention, deleted-instance behavior, and zero-value retention serialization/mapping.Written by Cursor Bugbot for commit 1104580. This will update automatically on new commits. Configure here.