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

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

Merged
ethanndickson merged 1 commit intomainfromethan/delete-old-connection-events
Jul 15, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedJul 3, 2025
edited
Loading

Breaking change (changelog note):

With new connection events appearing in the Connection Log, connection events older than 90 days will now be deleted from the Audit Log. If you require this legacy data, we recommend querying it from the REST API or making a backup of the database/these events before upgrading your Coder deployment. Please see the PR for details on what exactly will be deleted.
Of note is that there are currently no plans to delete connection events from the Connection Log.

Context

This is the fifth PR for moving connection events out of the audit log.

In previous PRs:

  • New connection logs have been routed to theconnection_logs table. They willnot appear in the audit log.
  • These new connection logs are served from the new/api/v2/connectionlog endpoint.

In this PR:

  • We'll now clean existing connection events out of the audit log, if they are older than 90 days, We do this in batches of 1000, every 10 minutes.

The criteria for deletion is simple:

WHERE(     action = 'connect'     OR action = 'disconnect'     OR action = 'open'     OR action = 'close')AND "time" < @before_time::timestamp with time zone

where@before_time is currently configured to 90 days in the past.

Future PRs:

  • Write documentation for the endpoint / feature

Copilot

This comment was marked as outdated.

@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch fromda6d50a to0386f5bCompareJuly 3, 2025 07:36
@ethanndicksonethanndickson marked this pull request as ready for reviewJuly 3, 2025 08:24
@github-actionsgithub-actionsbot added the release/breakingThis label is applied to PRs to detect breaking changes as part of the release process labelJul 3, 2025
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch from0386f5b toab296c6CompareJuly 3, 2025 08:30
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch fromab296c6 to8034bbfCompareJuly 10, 2025 05:58
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch from8034bbf to143bf38CompareJuly 10, 2025 10:29
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch from143bf38 tofd367a7CompareJuly 10, 2025 10:37
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch fromfd367a7 toa7f5137CompareJuly 10, 2025 10:50
Copy link
Contributor

@CopilotCopilotAI left a 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 forDeleteOldAuditLogConnectionEvents.
  • Hooks the deletion into the existingdbpurge 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
FileDescription
coderd/database/queries/auditlogs.sqlNewDELETE FROM audit_logs query definition
coderd/database/queries.sql.goSQL constant and executor method for the delete query
coderd/database/querier.goInterface addition for the new deletion method
coderd/database/dbpurge/dbpurge.goIntegrated deletion into the purge workflow
coderd/database/dbpurge/dbpurge_test.goTests verifying deletion logic and batch limits
coderd/database/dbmock/dbmock.goMock implementations for the new method
coderd/database/dbmetrics/querymetrics.goMetrics wrapper around the delete operation
coderd/database/dbauthz/dbauthz.goAuthorization guard for the deletion call
coderd/database/dbauthz/dbauthz_test.goAuthz test for the new deletion endpoint
Comments suppressed due to low confidence (1)

coderd/database/querier.go:99

  • [nitpick] Add a doc comment aboveDeleteOldAuditLogConnectionEvents in thesqlcQuerier interface to describe its behavior, matching the style of other interface methods.
DeleteOldAuditLogConnectionEvents(ctx context.Context, arg DeleteOldAuditLogConnectionEventsParams) error

@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch froma7f5137 tod370914CompareJuly 14, 2025 02:04
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch fromd370914 to20a639fCompareJuly 14, 2025 06:13
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch from20a639f to8a1d30bCompareJuly 15, 2025 03:33
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch from8a1d30b tocdf23a2CompareJuly 15, 2025 04:00
@ethanndicksonethanndickson changed the base branch fromethan/fe-connection-log tographite-base/18735July 15, 2025 05:04
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch fromcdf23a2 to325ab3eCompareJuly 15, 2025 05:12
@graphite-appgraphite-appbot changed the base branch fromgraphite-base/18735 tomainJuly 15, 2025 05:12
@ethanndicksonethanndicksonforce-pushed theethan/delete-old-connection-events branch from325ab3e toba228c9CompareJuly 15, 2025 05:12
@ethanndicksonethanndickson merged commitf42de9f intomainJul 15, 2025
55 of 56 checks passed
@ethanndicksonethanndickson deleted the ethan/delete-old-connection-events branchJuly 15, 2025 05:45
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 15, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

Copilot code reviewCopilotCopilot left review comments

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@ethanndicksonethanndickson

Labels
release/breakingThis label is applied to PRs to detect breaking changes as part of the release process
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ethanndickson@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp