Skip to content

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Dec 1, 2025

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

PR Title
#21021 feat(coderd): add retention policy configuration
#21022 feat(coderd/database/dbpurge): add retention for connection logs
#21025 feat(coderd/database/dbpurge): add retention for audit logs
👉 #21037 feat(coderd/database/dbpurge): make API keys retention configurable
#21038 docs: add data retention documentation
#21039 feat: add retention config for workspace_agent_logs

@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-4 branch 4 times, most recently from 008a48a to 03f5ec5 Compare December 1, 2025 18:07
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-3 branch from 07ae594 to 9ca58c3 Compare December 1, 2025 18:07
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-3 branch from 9ca58c3 to a21395a Compare December 2, 2025 10:02
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-4 branch from 03f5ec5 to 46f07e1 Compare December 2, 2025 10:05
@mafredri mafredri marked this pull request as ready for review December 2, 2025 10:29
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-3 branch from a21395a to 82f1c2b Compare December 2, 2025 11:37
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-4 branch from 46f07e1 to 27c90dd Compare December 2, 2025 11:37
user_id = $1;

-- name: DeleteExpiredAPIKeys :one
-- name: DeleteExpiredAPIKeys :execrows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah TIL!

Copy link
Member

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?

Copy link
Contributor

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... 🐦‍⬛

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crows.exe is beakoning.

@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-3 branch from 82f1c2b to 2ce8f62 Compare December 2, 2025 12:56
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-4 branch from 27c90dd to 1bed429 Compare December 2, 2025 12:56
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-3 branch 2 times, most recently from 8cb020d to 2a45adb Compare December 2, 2025 14:18
Base automatically changed from mafredri/feat-coderd-db-retention-policy-3 to main December 2, 2025 14:50
Replace hardcoded 7-day retention for expired API keys with configurable
retention from deployment settings. Falls back to global retention when
not set, and skips deletion entirely when effective retention is 0.

Depends on #21021
Updates #20743
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 the
extra CTE wrapper. This lets PostgreSQL return the row count directly
via RowsAffected() instead of requiring an explicit COUNT(*) scan.
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-4 branch from 1bed429 to a6744f0 Compare December 2, 2025 14:51
@mafredri mafredri enabled auto-merge (squash) December 2, 2025 14:55
@mafredri mafredri merged commit 9ec90cf into main Dec 2, 2025
30 checks passed
@mafredri mafredri deleted the mafredri/feat-coderd-db-retention-policy-4 branch December 2, 2025 15:41
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants