Commit 6019903
committed
feat: add prebuild invalidation via last_invalidated_at timestamp
Implements new approach for prebuild invalidation as discussed in issue #17917.
Instead of directly deleting workspaces, this sets a timestamp on presets,
and the reconciler automatically marks prebuilds as expired and creates new ones.
Implementation:
- Add last_invalidated_at column to template_version_presets table
- API endpoint: POST /templates/{template}/prebuilds/invalidate
- Updates last_invalidated_at = NOW() for all active template version presets
- filterExpiredWorkspaces checks if prebuild.created_at < preset.last_invalidated_at
- Reconciler automatically deletes expired prebuilds and spawns fresh ones
Changes:
- Migration 000394: Add last_invalidated_at column
- Query: UpdatePresetsLastInvalidatedAt sets timestamp on active presets
- API: Returns count and list of invalidated preset names
- Logic: filterExpiredWorkspaces prioritizes last_invalidated_at over TTL
- SDK: InvalidateTemplatePrebuilds client method with structured response
Benefits:
- Non-blocking: API doesn't wait for reconciler
- Async: Reconciler handles actual deletion
- Safe: template_version_presets is no longer write-once
Updates #179171 parent 2bcf084 commit 6019903
File tree
15 files changed
+241
-21
lines changed- coderd
- database
- dbauthz
- dbmetrics
- dbmock
- migrations
- queries
- prebuilds
- codersdk
15 files changed
+241
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1214 | 1214 | | |
1215 | 1215 | | |
1216 | 1216 | | |
| 1217 | + | |
1217 | 1218 | | |
1218 | 1219 | | |
1219 | 1220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4968 | 4968 | | |
4969 | 4969 | | |
4970 | 4970 | | |
| 4971 | + | |
| 4972 | + | |
| 4973 | + | |
| 4974 | + | |
| 4975 | + | |
| 4976 | + | |
| 4977 | + | |
| 4978 | + | |
| 4979 | + | |
| 4980 | + | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
4971 | 4985 | | |
4972 | 4986 | | |
4973 | 4987 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments