feat: add database purge for old provisioner job logs and timings by blink-so[bot] · Pull Request #18744 · coder/coder · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

feat: add database purge for old provisioner job logs and timings #18744

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

blink-so[bot]
Copy link
Contributor

@blink-so blink-so bot commented Jul 3, 2025

Summary

This PR implements a database purge feature for old provisioner job logs and timings to help manage database storage growth.

Changes

Database Migration

  • Added migration 000347_workspace_builds_purged_at to add a purged_at column to the workspace_builds table for tracking purged builds

SQL Queries

  • Added DeleteOldProvisionerJobLogs and DeleteOldProvisionerJobTimings queries in provisionerjobs.sql
  • Implements smart purging logic:
    • Deleted workspaces: Purge ALL logs/timings regardless of age
    • Active workspaces: Purge logs/timings older than 90 days (except for the latest build)

Database Purge Integration

  • Updated dbpurge.go to call the new deletion methods with a 90-day threshold
  • Integrated into the existing periodic purge process

Testing

  • Added comprehensive test TestDeleteOldProvisionerJobLogsAndTimings
  • Fixed test setup to properly create deleted workspaces for testing
  • All tests pass

Generated Code Updates

  • Updated database interfaces, mocks, and metrics wrappers
  • Regenerated dbmock to include new methods
  • Added missing methods to dbmetrics package

Testing

The implementation has been thoroughly tested:

  • ✅ Deleted workspace logs are purged regardless of age
  • ✅ Old logs from active workspaces are purged (90+ days, except latest build)
  • ✅ Recent logs and latest builds are preserved
  • ✅ All existing dbpurge tests continue to pass

Impact

This feature will help reduce database storage usage by automatically cleaning up old provisioner job logs and timings while preserving important recent data and the latest build information for active workspaces.

blink-so bot and others added 2 commits July 3, 2025 12:36
This commit implements a database purge feature for old provisioner job logs
and timings to help manage database storage:

- Add migration to add purged_at column to workspace_builds table
- Add SQL queries to delete old provisioner job logs and timings:
  * Purge all logs/timings from deleted workspaces
  * Purge logs/timings from non-deleted workspaces older than 90 days
    (except for the latest build)
- Update dbpurge.go to call the new deletion methods
- Add comprehensive tests for the purge behavior
- Fix test setup to properly create deleted workspaces for testing
- Update generated database interfaces and mocks

Tested: All dbpurge tests pass, including the new comprehensive test
for provisioner job log and timing purging.

Co-authored-by: dannykopping <373762+dannykopping@users.noreply.github.com>
- Update migration to recreate workspace_build_with_user view to include purged_at column
- Fix formatting issues in test file (spacing and extra blank line)
- This resolves the gen and fmt CI failures

Co-authored-by: dannykopping <373762+dannykopping@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.