- Notifications
You must be signed in to change notification settings - Fork1.1k
feat(coderd/database/dbpurge): make API keys retention configurable#21037
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:mafredri/feat-coderd-db-retention-policy-3
Are you sure you want to change the base?
feat(coderd/database/dbpurge): make API keys retention configurable#21037
Conversation
008a48a to03f5ec5Compare07ae594 to9ca58c3CompareAdd `RetentionConfig` with server flags for configuring data retention:- `--global-retention`: default policy for all retention settings- `--audit-logs-retention`: retention for audit log entries- `--connection-logs-retention`: retention for connection logs- `--api-keys-retention`: retention for expired API keys (default 7d)Updates#20743
Remove the global retention fallback in favor of explicit per-topicretention settings. This makes the retention behavior clearer andeasier for operators to reason about.Each retention setting now:- Enables retention when set to a non-zero duration- Disables retention (keep indefinitely) when set to 0
Connection logs retention is now explicit - it's enabled when--connection-logs-retention is set to a non-zero duration, anddisabled when set to 0. No fallback to global retention.
9ca58c3 toa21395aCompare03f5ec5 to46f07e1CompareUse :execrows instead of :one to simplify the query by removing theextra CTE wrapper. This lets PostgreSQL return the row count directlyvia RowsAffected() instead of requiring an explicit COUNT(*) scan.
a21395a to82f1c2bCompare46f07e1 to27c90ddCompare| user_id= $1; | ||
| -- name: DeleteExpiredAPIKeys :one | ||
| -- name: DeleteExpiredAPIKeys :execrows |
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.
woah TIL!
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.
@dannykopping have you seen this annotation?
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.
I haven't! Those crows should watch out... 🐦⬛
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.
crows.exe is beakoning.
Increase from 1000 to 10000 to improve deletion throughput for largedeployments. At 10 minute intervals, this allows purging up to 1.44Mrecords per day.
Add configurable retention policy for audit logs. The DeleteOldAuditLogsquery excludes deprecated connection events (connect, disconnect, open,close) which are handled separately by DeleteOldAuditLogConnectionEvents.Falls back to global retention if audit logs retention is unset.Disabled (0) by default.Depends on#21021Updates#20743
Audit logs retention is now explicit - it's enabled when--audit-logs-retention is set to a non-zero duration, anddisabled when set to 0. No fallback to global retention.
Use :execrows instead of :one to simplify the query by removing theextra CTE wrapper. This lets PostgreSQL return the row count directlyvia RowsAffected() instead of requiring an explicit COUNT(*) scan.
API keys retention is now explicit - it's enabled when--api-keys-retention is set to a non-zero duration (default 7d),and disabled when set to 0. No fallback to global retention.
Use :execrows instead of :one to simplify the query by removing theextra CTE wrapper. This lets PostgreSQL return the row count directlyvia RowsAffected() instead of requiring an explicit COUNT(*) scan.
82f1c2b to2ce8f62Compare27c90dd to1bed429Compare8cb020d to2a45adbCompare
Uh oh!
There was an error while loading.Please reload this page.
Replace hardcoded 7-day retention for expired API keys with configurable
retention from deployment settings. Skips deletion entirely when effective retention is 0.
Depends on#21021
Updates#20743
PR Stack
workspace_agent_logs