You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add scheduled instance snapshots with retention cleanup (#139)
* feat: add scheduled snapshots with retention cleanup
* fix: aggregate scheduled snapshot runner errors
* perf: scan schedule index and reduce lock contention
* fix: validate scheduled snapshot name prefix length
* refactor: move scheduled snapshot domain logic to lib package
* fix: ignore missing snapshots during retention cleanup
* chore: remove dead wrapper and align retention schema
* fix: tighten schedule run due-check under write lock
* feat: auto-select scheduled snapshot kind and retain post-delete schedules
* fix: return 404 when scheduling a missing instance
* fix: retire converged deleted-instance schedules
* chore: remove test-only snapshot schedule aliases
* fix: preserve schedule runtime history on updates
* fix: tighten schedule retention request handling
* fix: honor cancellation in schedule runner loop
* fix: preserve explicit zero retention settings
* fix: evaluate schedule timing per-instance
* fix: make schedule interval step arithmetic explicit
* simplify snapshot scheduling: extract error helper, inline thin wrappers, remove dead code
- Extract failScheduleRun helper to deduplicate the "record error + save
schedule" pattern repeated 4 times in runSnapshotScheduleForInstanceLocked
- Inline countScheduledSnapshots (single-use len() wrapper) at call site
- Inline validateSetSnapshotScheduleRequest (single-use wrapper) at call site
- Merge snapshot_schedule_types.go contents into snapshot_schedule.go
- Remove dead truncation/fallback code in BuildSnapshotName that could never
execute because ValidateSetRequest already rejects invalid prefixes upstream
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* deslop: remove redundant nil guards and unnecessary make
- Remove redundant nil-check-before-assign for pointer fields in
snapshotScheduleToOAPI (assigning nil to a nil field is a no-op)
- Use var declaration instead of make([]error, 0) for error accumulator
that is only appended to (not serialized to JSON)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* add snapshot-schedule routes to scope mappings
The scopes package (added on main) requires all routes to have scope
mappings. Map the three snapshot-schedule endpoints to existing snapshot
scopes: read, write, and delete.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix gofmt alignment in scope mappings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Harden snapshot schedule persistence and timing
* Fix manager formatting for CI
* Stabilize scheduled snapshot cleanup tests
* Add snapshot schedule routes to Stainless config
---------
Co-authored-by: sjmiller609 <7516283+sjmiller609@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: lib/instances/README.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,28 @@ Any State → Stopped
108
108
- Don't prefault pages (lazy loading)
109
109
- Parallel with TAP device setup
110
110
111
+
## Scheduled Snapshot Behavior
112
+
113
+
- Schedules are configured per instance and persisted in the server data store (outside snapshot payloads).
114
+
- A background scheduler evaluates due schedules every minute.
115
+
- Each due run chooses snapshot behavior from current source state:
116
+
-`Running`/`Standby` sources use `Standby` snapshots.
117
+
-`Stopped` sources use `Stopped` snapshots.
118
+
-`Standby` runs from `Running` sources perform a brief pause/resume cycle during capture.
119
+
- The minimum interval is `1m`, but larger intervals are recommended for heavier or latency-sensitive workloads because running captures pause/resume the guest.
120
+
- Scheduled snapshot `name_prefix` is optional and capped at 47 chars so generated names stay within the 63-char snapshot name limit.
121
+
- New schedules establish cadence at `now + interval + deterministic jitter` derived from the instance ID.
122
+
- Updating only retention, metadata, or `name_prefix` preserves `next_run_at`; changing `interval` establishes a new cadence.
123
+
- Schedule runs advance to the next future interval (no backfill flood after downtime).
124
+
- Each schedule stores operational status:
125
+
-`next_run_at`
126
+
-`last_run_at`
127
+
-`last_snapshot_id`
128
+
-`last_error`
129
+
- Retention cleanup runs after successful scheduled snapshot creation and only affects scheduled snapshots for that instance.
130
+
- If an instance is deleted, its schedule is retained so retention can continue cleaning existing scheduled snapshots.
131
+
- Once the deleted instance has no scheduled snapshots left, the scheduler removes that schedule automatically.
0 commit comments