- Notifications
You must be signed in to change notification settings - Fork947
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
to4be35f4
Compareda6d50a
to0386f5b
Compare4be35f4
to9239251
Compare0386f5b
toab296c6
Compare9239251
to7f2dccd
Compareab296c6
to8034bbf
Compare7f2dccd
tod6ec519
Compare8034bbf
to143bf38
Compared6ec519
to15aac3f
Compare143bf38
tofd367a7
Compare15aac3f
toc505c02
Comparefd367a7
toa7f5137
CompareThere 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
dbpurge
ticker 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
DeleteOldAuditLogConnectionEvents
in thesqlcQuerier
interface to describe its behavior, matching the style of other interface methods.
DeleteOldAuditLogConnectionEvents(ctx context.Context, arg DeleteOldAuditLogConnectionEventsParams) error
Uh oh!
There was an error while loading.Please reload this page.
c505c02
to9238f25
Comparea7f5137
tod370914
Compare9238f25
to823dc41
Compared370914
to20a639f
Compare823dc41
toe364d00
Compare20a639f
to8a1d30b
Comparee364d00
tocf9592b
Compare8a1d30b
tocdf23a2
Comparecf9592b
tob5260d5
Comparecdf23a2
to325ab3e
Compare325ab3e
toba228c9
Comparef42de9f
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_logs
table. They willnot appear in the audit log./api/v2/connectionlog
endpoint.In this PR:
The criteria for deletion is simple:
where
@before_time
is currently configured to 90 days in the past.Future PRs: