Skip to content

feat(coderd/database/dbpurge): retain most recent agent build logs #14460

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

Merged
merged 9 commits into from
Aug 30, 2024
Prev Previous commit
Next Next commit
ensure that ticks from quartz are dbtimey
  • Loading branch information
johnstcn committed Aug 30, 2024
commit 725eeb0ee651acf2835ab499269f5c72be0b5a98
6 changes: 4 additions & 2 deletions coderd/database/dbpurge/dbpurge.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/quartz"
)

Expand Down Expand Up @@ -47,7 +48,8 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.
return nil
}

if err := tx.DeleteOldWorkspaceAgentLogs(ctx, start.Add(-maxAgentLogAge)); err != nil {
deleteOldWorkspaceAgentLogsBefore := start.Add(-maxAgentLogAge)
if err := tx.DeleteOldWorkspaceAgentLogs(ctx, deleteOldWorkspaceAgentLogsBefore); err != nil {
return xerrors.Errorf("failed to delete old workspace agent logs: %w", err)
}
if err := tx.DeleteOldWorkspaceAgentStats(ctx); err != nil {
Expand Down Expand Up @@ -78,7 +80,7 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.
return
case tick := <-ticker.C:
ticker.Stop()
doTick(tick)
doTick(dbtime.Time(tick).UTC())
}
}
}()
Expand Down