Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
mafredri wants to merge18 commits intomafredri/feat-coderd-db-retention-policy-3
base:mafredri/feat-coderd-db-retention-policy-3
Choose a base branch
Loading
frommafredri/feat-coderd-db-retention-policy-4

Conversation

@mafredri
Copy link
Member

@mafredrimafredri commentedDec 1, 2025
edited by dannykopping
Loading

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

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

Add `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
Add `DeleteOldConnectionLogs` query and integrate it into the `dbpurge`routine. Retention is controlled by `--retention-connection-logs` flag,falling back to `--retention-global` when not set. Disabled (0) bydefault.Depends on#21021Updates#20743
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.
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch from9ca58c3 toa21395aCompareDecember 2, 2025 10:02
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-4 branch from03f5ec5 to46f07e1CompareDecember 2, 2025 10:05
@mafredrimafredri marked this pull request as ready for reviewDecember 2, 2025 10:29
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.
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch froma21395a to82f1c2bCompareDecember 2, 2025 11:37
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-4 branch from46f07e1 to27c90ddCompareDecember 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
MemberAuthor

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.
Replace hardcoded 7-day retention for expired API keys with configurableretention from deployment settings. Falls back to global retention whennot set, and skips deletion entirely when effective retention is 0.Depends on#21021Updates#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 theextra CTE wrapper. This lets PostgreSQL return the row count directlyvia RowsAffected() instead of requiring an explicit COUNT(*) scan.
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch from82f1c2b to2ce8f62CompareDecember 2, 2025 12:56
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-4 branch from27c90dd to1bed429CompareDecember 2, 2025 12:56
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch 2 times, most recently from8cb020d to2a45adbCompareDecember 2, 2025 14:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@EmyrkEmyrkEmyrk approved these changes

Assignees

@mafredrimafredri

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@mafredri@dannykopping@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp