-
Notifications
You must be signed in to change notification settings - Fork 943
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5db1b73
to
4be35f4
Compare
da6d50a
to
0386f5b
Compare
4be35f4
to
9239251
Compare
0386f5b
to
ab296c6
Compare
9239251
to
7f2dccd
Compare
ab296c6
to
8034bbf
Compare
7f2dccd
to
d6ec519
Compare
8034bbf
to
143bf38
Compare
d6ec519
to
15aac3f
Compare
143bf38
to
fd367a7
Compare
15aac3f
to
c505c02
Compare
fd367a7
to
a7f5137
Compare
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.
Pull Request Overview
Adds a new cleanup routine to remove old “connect”, “disconnect”, “open”, and “close” events from the audit_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 | New DELETE 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
c505c02
to
9238f25
Compare
a7f5137
to
d370914
Compare
9238f25
to
823dc41
Compare
d370914
to
20a639f
Compare
823dc41
to
e364d00
Compare
20a639f
to
8a1d30b
Compare
e364d00
to
cf9592b
Compare
8a1d30b
to
cdf23a2
Compare
cf9592b
to
b5260d5
Compare
cdf23a2
to
325ab3e
Compare
325ab3e
to
ba228c9
Compare
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 will not 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: