- Notifications
You must be signed in to change notification settings - Fork1.1k
chore!: delete old connection events from audit log#18735
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ethanndickson commentedJul 3, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
5db1b73 to4be35f4Compareda6d50a to0386f5bCompare4be35f4 to9239251Compare0386f5b toab296c6Compare9239251 to7f2dccdCompareab296c6 to8034bbfCompare7f2dccd tod6ec519Compare8034bbf to143bf38Compared6ec519 to15aac3fCompare143bf38 tofd367a7Compare15aac3f toc505c02Comparefd367a7 toa7f5137CompareThere 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.
Pull Request Overview
Adds a new cleanup routine to remove old “connect”, “disconnect”, “open”, and “close” events from theaudit_logs table (older than 90 days) in 1,000-row batches every 10 minutes.
- Introduces a SQL command and Go wrapper for
DeleteOldAuditLogConnectionEvents. - Hooks the deletion into the existing
dbpurgeticker loop, with tests, metrics, mocks, and authz rules. - Updates interfaces, mocks, and authorization policies to support the new operation.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| coderd/database/queries/auditlogs.sql | NewDELETE FROM audit_logs query definition |
| coderd/database/queries.sql.go | SQL constant and executor method for the delete query |
| coderd/database/querier.go | Interface addition for the new deletion method |
| coderd/database/dbpurge/dbpurge.go | Integrated deletion into the purge workflow |
| coderd/database/dbpurge/dbpurge_test.go | Tests verifying deletion logic and batch limits |
| coderd/database/dbmock/dbmock.go | Mock implementations for the new method |
| coderd/database/dbmetrics/querymetrics.go | Metrics wrapper around the delete operation |
| coderd/database/dbauthz/dbauthz.go | Authorization guard for the deletion call |
| coderd/database/dbauthz/dbauthz_test.go | Authz test for the new deletion endpoint |
Comments suppressed due to low confidence (1)
coderd/database/querier.go:99
- [nitpick] Add a doc comment above
DeleteOldAuditLogConnectionEventsin thesqlcQuerierinterface to describe its behavior, matching the style of other interface methods.
DeleteOldAuditLogConnectionEvents(ctx context.Context, arg DeleteOldAuditLogConnectionEventsParams) errorUh oh!
There was an error while loading.Please reload this page.
c505c02 to9238f25Comparea7f5137 tod370914Compare9238f25 to823dc41Compared370914 to20a639fCompare823dc41 toe364d00Compare20a639f to8a1d30bComparee364d00 tocf9592bCompare8a1d30b tocdf23a2Comparecf9592b tob5260d5Comparecdf23a2 to325ab3eCompare325ab3e toba228c9Comparef42de9f intomainUh oh!
There was an error while loading.Please reload this page.

Uh oh!
There was an error while loading.Please reload this page.
Breaking change (changelog note):
Context
This is the fifth PR for moving connection events out of the audit log.
In previous PRs:
connection_logstable. They willnot appear in the audit log./api/v2/connectionlogendpoint.In this PR:
The criteria for deletion is simple:
where
@before_timeis currently configured to 90 days in the past.Future PRs: